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}$.

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$.
