49. (USS 3) Find all pairs of integers $(p, q)$ for which all roots of the trinomials $x^{2}+p x+q$ and $x^{2}+q x+p$ are integers.
49. If one of $p, q$, say $p$, is zero, then $-q$ is a perfect square. Conversely, $(p, q)=\left(0,-t^{2}\right)$ and $(p, q)=\left(-t^{2}, 0\right)$ satisfy the conditions for $t \in \mathbb{Z}$. We now assume that $p, q$ are nonzero. If the trinomial $x^{2}+p x+q$ has two integer roots $x_{1}, x_{2}$, then $|q|=\left|x_{1} x_{2}\right| \geq\left|x_{1}\right|+\left|x_{2}\right|-1 \geq|p|-1$. Similarly, if $x^{2}+q x+p$ has integer roots, then $|p| \geq|q|-1$ and $q^{2}-4 p$ is a square. Thus we have two cases to investigate:
(i) $|p|=|q|$. Then $p^{2}-4 q=p^{2} \pm 4 p$ is a square, so $(p, q)=(4,4)$.
(ii) $|p|=|q| \pm 1$. The solutions for $(p, q)$ are $(t,-1-t)$ for $t \in \mathbb{Z}$ and $(5,6)$, $(6,5)$.