Direct sum of cohomology rings. How to interpret?

Consider the space $Y:= M(\mathbb{Z}_p, 2) \vee S^4)$ where $M(\mathbb{Z}_p, 2)$ is a Moore space, i.e having trivial homology groups for all $i \neq 0,2$ where $H_0(M) \cong \mathbb{Z}$ and $H_2(M) \cong \mathbb{Z}_p$.

Hatcher gives me the following isomorphism

$$H^*(M \vee S^4 ; \mathbb{Z}_p) \cong H^*(\mathbb{M}, \mathbb{Z}_p) \times H^*(S^4, \mathbb{Z}_p )$$

I have found that for all but $i=0,1,2,3,4$ the cohomology group $H^i(Y)$ trivial. For $i=0,1,2,3,4$ the cohomology group of $H^i(Y) \cong \mathbb{Z}_p$.

Anyway, I am pretty confused because Hatcher seems to be working from the "top down" and I don't understand how to exactly relate the cohomology rings to the cohomology groups.

$H^i(M)=0$ for all $i \neq 0,2$. Thus the cup product structure, and therefor the cohomology ring, depend only on $1$,$\alpha$ where $\alpha$ generates $H^2(M)$. Similarly, the only nontrivial generators of cohomology groups of $H^i(S^4)$ are $1$ and $\beta$ where $\beta$ generates $H^4(S^4, \mathbb{Z}_p)$.

For both $\alpha$, $\beta$ we have that $\alpha^2=0$ and $\beta^2=0$ since all other cohomology groups are trivial.

How do I combine the cup products structures on $M$ and $S^4$ and relate them to $H^*(M \vee S^4)$?

How does the direct sum operate on the generators of the cohomology groups? How exactly is $\times$ defined on the ground level of cohomology groups??