2. Find all pairs of prime numbers $(p, q)$ such that the value of the expression $p^{2}+5 p q+4 q^{2}$ is a square of an integer.
2. Suppose that prime numbers $p, q$ and a positive integer $k$ satisfy the equation $p^{2}+5 p q+4 q^{2}=k^{2}$. We can equivalently rearrange this as:

$$
\begin{aligned}
k^{2}-\left(p^{2}+4 p q+4 q^{2}\right) & =p q, \\
k^{2}-(p+2 q)^{2} & =p q \\
(k-p-2 q)(k+p+2 q) & =p q .
\end{aligned}
$$

Both the right-hand side and the second factor on the left-hand side are positive, so the first factor must also be positive. Since $p, q$ are prime numbers, the number $p q$ can be factored into a product of two positive numbers in only four ways: $p q=1 \cdot p q=p \cdot q=q \cdot p=p q \cdot 1$. Given that the number $k+p+2 q$ is greater than any element of the set $\{1, p, q\}$, only the first factorization is possible, so

$$
k-p-2 q=1 \quad \text { and } \quad k+p+2 q=p q .
$$

By eliminating the variable $k$ (e.g., by subtracting the first equation from the second), we get

$$
2 p+4 q=p q-1 \quad \text { or } \quad(p-4)(q-2)=9
$$

The factor $q-2$ is non-negative because $q$ is a prime number. Therefore, the factor $p-4$ must also be non-negative. There are exactly three ways to factor the number 9 into a product of two non-negative numbers:

$$
9=1 \cdot 9=3 \cdot 3=9 \cdot 1 \text {. }
$$

From these, we get three solutions $(p, q) \in\{(5,11),(7,5),(13,3)\}$, and all the found values of $p, q$ are indeed prime numbers. Verification is not necessary because if $p, q$ satisfy equation (3), we can compute the integer $k$ from (2) such that equation (1) holds, which is equivalent to the original equation.

Another solution. Substituting $q=p$ into the given expression yields $10 p^{2}$, which is not a perfect square of any integer. Therefore, $p \neq q$.

The given expression can be factored as:

$$
p^{2}+5 p q+4 q^{2}=(p+q)(p+4 q) .
$$

Since the prime numbers $p$ and $q$ are different, each of them is coprime with $p+q$. Let $d$ be the greatest common divisor of the numbers $p+q$ and $p+4 q$. Then $d \mid(p+4 q)-(p+q)=3 q$, and since $d$ is coprime with $q$, necessarily $d \in\{1,3\}$. We will consider both cases.

If $d=1$, both factors in (4) must be perfect squares, i.e., there exist natural numbers $r, s$ such that

$$
\begin{aligned}
p+q & =r^{2} \\
p+4 q & =s^{2} .
\end{aligned}
$$

Moreover, it is clear that $2p+q \geqq 2+3$. Combining both equations in the system (5), we get

$$
\begin{gathered}
3 q=(p+4 q)-(p+q)=s^{2}-r^{2}=(s-r)(s+r), \\
3 p=4(p+q)-(p+4 q)=4 r^{2}-s^{2}=(2 r-s)(2 r+s) .
\end{gathered}
$$

From the first equation, it follows that $s-r \mid 3 q$, i.e., $s-r \in\{1,3, q, 3 q\}$. However, the cases $s-r=q$ and $s-r=3 q$ can be excluded because they correspond to the equations $s+r=3$ and $s+r=1$, which contradict the condition $23$ and $2 r-s=r-1>1$. From the second equation, it follows that $2 r+s=p$ and $2 r-s=3$, so $r=4, s=5, p=13, q=3$.

$\triangleright \mathrm{Z} s-r=3$ implies $2 r+s=3 r+3=3(r+1)>3$, so according to the second equation, $2 r-s<p$ and $2 r-s \in\{1,3\}$. If $2 r-s=3$, then $r=6$, $s=9$, and $p=2 r+s=21$, which is not a prime number. Therefore, $2 r-s=1$ and $2 r+s=3 p$, so $r=4, s=7, p=5, q=11$.

If $d=3$, both factors in (4) must be three times perfect squares, so there exist natural numbers $1<r<s$ such that

$$
\begin{aligned}
p+q & =3 r^{2} \\
p+4 q & =3 s^{2}
\end{aligned}
$$

Thus,

$$
\begin{gathered}
3 q=(p+4 q)-(p+q)=3(s-r)(s+r) \\
3 p=4(p+q)-(p+4 q)=3(2 r-s)(2 r+s)
\end{gathered}
$$

Therefore, $s-r=1$ and $2 r-s=1$, so $r=2, s=3$ and $p=7, q=5$.

In all cases, the found values of $p, q$ and the corresponding values of $r, s$ satisfy equations (5) or (6), so the expression (4) is indeed a perfect square.

The problem has three solutions $(p, q)$, namely $(13,3),(5,11),(7,5)$.

For a complete solution, award 6 points. For the first method, award 2 points for the factorization (1), another 2 points for deriving the factorization (3), and 2 points for completing the solution. For the second method, award 2 points for finding the factorization (4), 2 points for investigating the case $d=1$, and 2 points for investigating the case $d=3$. If the solver does not solve the problem but finds at least two of the three solutions by trial, award 1 point.