3. Find the maximum value of the expression $x^{2}+y^{2}+z^{2}$, if $x, y, z$ are integers satisfying the system

$$
\left\{\begin{array}{l}
x y+x+y=20 \\
y z+z+y=6 \\
x z+x+z=2
\end{array}\right.
$$
Solution. Adding 1 to both sides of each equation in the system, we get:

$$
\left\{\begin{array}{l}
x y + x + y + 1 = 21 \\
y z + z + y + 1 = 7 \\
x z + x + z + 1 = 3
\end{array}\right.
$$

Factoring the left-hand sides, we obtain:

$$
\left\{\begin{array}{l}
(x+1)(y+1) = 21 \\
(y+1)(z+1) = 7 \\
(z+1)(x+1) = 3
\end{array}\right.
$$

Multiplying the left and right sides of the obtained equations, we arrive at the equality $((x+1)(y+1)(z+1))^2 = 21^2$. There are two cases:

1) $(x+1)(y+1)(z+1) = 21$. Considering that the factors are of the same sign (which follows from the form of the last system), we get $x+1=3, y+1=7, z+1=1$ (the order may be different, but it does not affect the final answer), so $x=2, y=6, z=0$, hence $x^2 + y^2 + z^2 = 2^2 + 6^2 + 0^2 = 40$.

2) $(x+1)(y+1)(z+1) = -21$. Since the factors are of the same sign, we get $x+1=-3, y+1=-7, z+1=-1$ (the order may be different, but it does not affect the final answer), so $x=-4, y=-8, z=-2$, hence $x^2 + y^2 + z^2 = (-4)^2 + (-8)^2 + (-2)^2 = 84$.

Answer: 84.