Using the inverses of numbers modulo $n$, find a general formula for solving systems of equations falling under the Chinese Remainder Theorem.

Recall that Euler's totient function $\varphi(n)$ is the number of integers coprime to $n$ in the set $\{0, \ldots, n-1\}$.
The solutions to the system of equations $x \equiv a_{i}\left(\bmod m_{i}\right)$ for $i$ ranging from 1 to $r$, are exactly the numbers $x$ congruent to the following number modulo $m_{1} m_{2} \cdots m_{r}$:

$$
a_{1} i_{1}\left(m_{2} m_{3} \cdots m_{r}\right)+a_{2} i_{2}\left(m_{1} m_{3} m_{4} \cdots m_{r}\right)+\cdots+a_{r} i_{r}\left(m_{1} m_{2} \cdots m_{r-1}\right)
$$

where $i_{k}$ is a representative in $\mathbb{Z}$ of the inverse of $m_{1} m_{2} \cdots m_{k-1} m_{k+1} \cdots m_{r}$ modulo $m_{k}$.

Indeed, modulo $m_{1}$ for example, in the sum above all terms disappear except $a_{1} i_{1}\left(m_{2} m_{3} \ldots m_{r}\right) \equiv a_{1}\left(\bmod m_{1}\right)$ by definition of $i_{1}$. And similarly for $m_{2}, m_{3}$, etc.