Find the cardinality of the set Hom$(\mathbb{Z}_{n_1}\oplus \cdots \oplus \mathbb{Z}_{n_r}, \mathbb{Z}_{m_1}\oplus \cdots \oplus \mathbb{Z}_{m_s})$?

I know that the number of group homomorphism between $\mathbb{Z}_n$ to $\mathbb{Z}_m$ is $\gcd(n, m)$. With some other relevant information like Aut$(\mathbb{Z}_n)$ is isomorphic to $U(n)$ (viz the group of units of $\mathbb{Z}_n$), I was trying to find out what should be then the number of homomorphism between Aut$(\mathbb{Z}_n)$ and Aut$(\mathbb{Z}_m)$ leading to the query: what is actually $|Hom(U(n), U(m))|$.

So I started like this. If $n, m$ are of prime power like $p^{k_n}$ and $p^{k_m}$ respectively then using the fact $U(p^a)\simeq \mathbb{Z}_{p^a - p^{a-1}}$ we see that $$|Hom(U(n), U(m))|= |Hom(\mathbb{Z}_{p^{k_n} - p^{{k_n}-1}}, \mathbb{Z}_{p^{k_m} - p^{{k_m}-1}})|=\gcd(p^{k_n} - p^{{k_n}-1}, p^{k_m} - p^{{k_m}-1})$$

Now using the fact if $m, n$ are relatively prime then $U(mn)\simeq U(m)\oplus U(n)$, we see that $$U(p_1^{k_1}p_2^{k_2}\cdots p_r^{k_r})\simeq U(p_1^{k_1})\oplus U(p_2^{k_2})\oplus \cdots \oplus U(p_r^{k_r})\\\simeq \mathbb{Z}_{p_1^{k_1} - p_1^{{k_1}-1}}\oplus \mathbb{Z}_{p_2^{k_2} - p_2^{{k_2}-1}}\oplus \cdots \oplus \mathbb{Z}_{p_r^{k_2} - p_2^{{k_r}-1}}$$

In other words, if we need to know the cardinality of the set Hom$(U(n), U(m))$ we need to know the cardinality of the set Hom$(\mathbb{Z}_{n_1}\oplus \cdots \oplus \mathbb{Z}_{n_r}, \mathbb{Z}_{m_1}\oplus \cdots \oplus \mathbb{Z}_{m_s})$. I got stuck here. I have no idea what to do. Please help me on this regard. Thanks in advance.

-
Did you try it for a small example to try to catch the pattern? Why not try $\text{Hom}(\mathbb{Z}_2\oplus \mathbb{Z}_2,\mathbb{Z}_2 \oplus \mathbb{Z}_3)$ for example or $\text{Hom}(\mathbb{Z}_2\oplus \mathbb{Z}_2,\mathbb{Z}_2 \oplus \mathbb{Z}_3)$. You can easily see a pattern, formulate a conjecture, then prove it. –  mathematics2x2life Nov 26 '13 at 16:21

Hint: Show using universal property of product and coproduct that $Hom(A_1\oplus ...\oplus A_n,B)\cong Hom(A_1,B)\oplus ... \oplus Hom(A_n,B)$ and $Hom(B,A_1\oplus ...\oplus A_n)\cong Hom(,B,A_1)\oplus ... \oplus Hom(B,A_n)$. (Its important that this is finite direct sum!!!)
Sir , one more doubt. The isomorphism you showed above is it valid for all groups $A_i, B$ or is it valid for only Abelian groups? In the later case, shall we consider only finite Abelian groups only? –  Anjan Debnath Nov 27 '13 at 8:29
Its valid for any $R$ modules not finitely generated too (abelian groups are modules). Not for nonabelian group tho. Its true for modules because product of finitely and coproduct of finite number of modules is the same. For noncommutative groups coproduct is more complicated. –  user52045 Nov 27 '13 at 10:24