Proving a function $f:\mathbb{Z}_{nm} \rightarrow \mathbb{Z}_n \times \mathbb{Z}_m$ is an isomorphism 
Let $n,m$ be two coprime numbers. Prove that the function $f:\mathbb{Z}_{nm} \rightarrow \mathbb{Z}_n \times \mathbb{Z}_m$ such that  $f(\overline{r})=(\overline{r},\overline{r})$ is an isomorphism between rings.

I've already proven that $f$ is an homomorphism but I'm struggling with the bijectivity part.
Surjectivity:
We have to prove that for any $(\overline{a},\overline{b}) \in \mathbb{Z}_n \times \mathbb{Z}_m$ there exists $\overline{r} \in \mathbb{Z}_{nm}$ such that  $(\overline{r},\overline{r})=(\overline{a},\overline{b})$. But I don't know how to find such $\overline{r}$. However there are two requirements that such $\overline{r}$ has to meet:
$\overline{a}=\overline{r}  \iff a \equiv r \pmod n \iff a-r = c_1 n$
$\overline{b}=\overline{r}  \iff b \equiv r \pmod m \iff b-r = c_2 m$
But I don't really know how to continue from here.
Injectivity:
We have to prove that if $\overline{a} \neq \overline{b} \implies  (\overline{a},\overline{a})\neq(\overline{b},\overline{b})$. However I don't see why two elements of $\mathbb{Z}_{nm}$ being different implies they are different in both $\mathbb{Z}_{n}$ and $\mathbb{Z}_{m}$.
 A: You first have to prove the map is well defined.
Define
$$
g\colon\mathbb{Z}\to\mathbb{Z}_n\times\mathbb{Z}_m
\qquad
g(r)=(\bar{r},\bar{r})
$$
This is a ring homomorphism with no assumption on $m$ and $n$. The kernel is
$$
\ker g=\{r\in\mathbb{Z}:r\in n\mathbb{Z}\cap m\mathbb{Z}\}=k\mathbb{Z}
$$
where $k=\operatorname{lcm}(n,m)$, by well known results on ideals in the ring of integers. Granted that $n$ and $m$ are coprime (which probably is what your exercise tells you), you have $\operatorname{lcm}(n,m)=nm$.
The homomorphism theorem therefore provides a unique injective ring homomorphism
$$
f\colon\mathbb{Z}_{nm}\to\mathbb{Z}_n\times\mathbb{Z}_m
$$
such that $f(\bar{r})=g(r)=(\bar{r},\bar{r})$.
Since $f$ is injective and domain and codomain have the same number of elements, $f$ is also surjective.
A: Since  you already proved that $f$ is an homomorphism, we need to find $\ker f=\{0_{nm}\}$ to prove that $f$ is injective. So let $x_{nm}\in \ker f$, we have $f(x_{nm})=(x_n,x_m)=(0_n,0_m)\iff x$ is multiple of $n$ and $m$ and then multiple of $lcm(n,m)=nm$. Hence $\overline x=0_{nm}$. Now, since the cardinals of  $\Bbb Z_{nm}$ and $\Bbb Z_n\times \Bbb Z_m$ are equal, $f$ is then bijective.
A: Show that every element of $\mathbb Z_{mn}$ can be written uniquely in the form $am+bn$, with $0\le a<n$ and $0\le b < m$. To do this, you need only show that all of the elements of the form $am+bn$ are distinct modulo $mn$, for $0\le a<n$ and $0\le b<m$. Once you've shown that, you know the map $f$ is of the form $f(am+bn)=(a,b)$, which is clearly bijective.
Given two such numbers, $am+bn$ and $cm+dn$, then if these were equivalent modulo $mn,$ you would have
$$
(a-c)m\equiv (d-b)n\pmod{mn}
$$
which implies that for some integer $k$,
$$
(a-c)m = (d-b)n + kmn
$$
The RHS is divisible by $n$, so the LHS is as well. Since $m$ and $n$ are coprime, this implies $n$ divides $a-c$, which since $a,c\in [0,n)$ implies $a=c$. Rearraning the equation to 
$$
(a-c)m -kmn= (d-b)n 
$$
allows you to use the same logic to conclude $d=b$, proving uniqueness.
A: Surjectivity, in particular, $n,m$ are relatively prime. $um+vn=1$ implies that $r=anv+bmu$. 
Injectivity, $(\bar r,\bar r)=(\bar 0,\bar 0)$ implies that $r(um+vn)=r=0$ mod $m$ this implies that $rvn=0$ mod $m$ and $m$ divides $rv$, we deduce that $m$ divides $r$, since $m$ cannot divides $v$ since $um+rv=1$.
