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