4. Given the functions $f(x)=x^{2}+4 x+3$ and $g(x)=x^{2}+2 x-1$. Find all integer solutions to the equation $f(g(f(x)))=g(f(g(x)))$.
4. Answer. $x=-2$. Solution. Let's represent the functions as $f(x)=x^{2}+4 x+3=(x+2)^{2}-1$ and $g(x)=x^{2}+2 x-1=(x+1)^{2}-2 . \quad$ Then $\quad f(g(x))=\left((x+1)^{2}-2+2\right)^{2}-1=(x+1)^{4}-1$, $g(f(x))=\left((x+2)^{2}-1+1\right)^{2}-2=(x+2)^{4}-2$. Performing similar operations, we get $g(f(g(x)))=(x+1)^{8}-2$ and $f(g(f(x)))=(x+2)^{8}-1$. Thus, the equation is

$$
\begin{gathered}
(x+1)^{8}-(x+2)^{8}=1 \\
\left((x+1)^{4}-(x+2)^{4}\right)\left((x+1)^{4}+(x+2)^{4}\right)=1
\end{gathered}
$$

Obviously, the second bracket can only be equal to 1, which means the first bracket is also equal to 1. This system has a unique solution $x=-2$.

Grading criteria. Correct solution - 7 points, all function compositions are correctly written but the solution is incomplete or incorrect - 2 points, the solution is incorrect or only the answer - $\mathbf{0}$ points.