<s>[INST] Find all $x\in \mathbb{Z}$ with $x \equiv 2 \mod 4$ , $x \equiv 8\mod9$ and $x \equiv 1\mod5$ 
Find all $x\in \mathbb{Z}$ with $x \equiv 2 \mod 4$ , $x \equiv 8\mod9$ and $x \equiv 1\mod5$

My attempt:
$\gcd\left(9,5,4\right) = 1 = 9r+5s+4\times0$
$9 = 1\times5+4$
$5 = 1\times4+1$
so $1 = 5-(9-5) = 2\times5 - 1\times9$
thus $r=-1$ and $s = 2$
so $x = 2\times5\times8 -1\times9\times1=80 - 9=71\mod 180$
But the problem is that $71\equiv8\mod9$ and $71\equiv1\mod5$, but $71 \ne 2 \mod 4$. What is wrong?
 [/INST] I am using the method for solving this system of equations as outlined here.

Here, we have $a_1 = 2, a_2 = 8, a_3 = 1$. Additionally, $n_1 = 4, n_2 = 9, n_3 = 5$. Now, $N = n_1 \cdot n_2 \cdot n_3 = 180$.
Hence, $y_1 = 45, y_2 = 20, y_3 = 36$. Now, we are supposed to find the values of $z_i$ for $i = 1, 2, 3$. I'll outline the method for finding $z_1$, and the others follow similarly.
Now, $z_1 \equiv 45^{-1} \mod 4$. Now, what is the value of $45^{-1}$? It is that value of $x \in \mathrm{Z_4}$ such that $$45x \equiv 1 \mod 4$$ We can easily see that $x = 1$. So, we get: $z_1 \equiv 1 \mod 4$, which gives $z_1 = 1$.

Can you take it from here? 
</s>