I will state the Chinese remainder theorem here:
Let $R$ be a ring and $I_1,\ldots I_n$ ideals of $R$. Mapping $\varphi:R\rightarrow \prod _{k=1}^nR/I_k$ defined by $\varphi:r\mapsto (r+I_1,\ldots,r+I_n).$ is a ring homomorphism with kernel $\ker \varphi = \bigcap_{k=1}^n I_k$. In addition, if $I_k$ are pairwise comaximal, then $\varphi$ is surjective and $\bigcap_{k=1}^nI_k=\prod_{k=1}^nI_k$ and thus, by the first isomorphism theorem $$ R/\prod_{k=1}^nI_k=R/\bigcap_{k=1}^nI_k\simeq \prod_{k=1}^n R/I_k $$
I managed to prove the following corollary applied to $R=\mathbb{Z}$:
Let $n_1,\ldots,n_k$ be pairwise coprime integers and $a_1,\ldots,a_k$ arbitrary integers. Given a system of congruences: $$ x \equiv a_1 \mod n_1 \\ x \equiv a_2 \mod n_2 \\ \ldots \\ x \equiv a_k \mod n_k $$ there exists solution $x\in\mathbb{Z}$ and is unique $\mod n=\prod_{i=1}^kn_i$.
Proof. Set $R=\mathbb{Z}$ and $I_i = \mathbb{Z} / n_i\mathbb{Z}$, fact that $n_i,n_j$ are pairwise coprime exactly corresponds to the fact that $rn_i+sn_j=1$ for some $r,s$ in other worse $I_i,I_j$ are pairwise comaximal ideals. By the Chinese remainder theorem we have an element $x\in \mathbb{Z}/n_1\ldots n_k\mathbb{Z}$ which maps to $(a_1+n_1\mathbb{Z},\ldots,a_k+n_k\mathbb{Z})$, and is unique because of the isomorphism $R/\bigcap_{k=1}^nI_k\simeq \prod_{k=1}^n R/I_k$.
Now, to my question. I wish to show the generalised corollary, using similar ideas:
Let $n_1,\ldots,n_k,a_1,\ldots,a_k$ be integers. Given a system of congruences: $$ x \equiv a_1 \mod n_1 \\ x \equiv a_2 \mod n_2 \\ \ldots \\ x \equiv a_k \mod n_k $$ If $\gcd(n_i,n_j)$ divides $a_i-a_j$ for any two $i\neq j$, then there is a solution to the above system of congruences. In addition, it is unique $\mod \operatorname{lcm}(n_1,\ldots,n_j)$.
Try. Set $R,I_k$ as above, fact that $a_i-a_j$ means exactly $rn_i+sn_j=a_i-a_j$ for some $r,s$,... but how to get the assumptions to apply CRT?