Task 4. Determine all pairs $(p, q)$ of prime numbers for which $p^{q+1}+q^{p+1}$ is a square.
Solution. First, assume that $p$ and $q$ are both odd. Then in $p^{q+1}+q^{p+1}$, both exponents are even, which implies that both terms are congruent to $1 \bmod 4$. The sum is thus congruent to 2 $\bmod 4$, but that is never a square.

Now assume that $p$ and $q$ are both even. Then they are both equal to 2. This gives $p^{q+1}+q^{p+1}=$ $2^{3}+2^{3}=16=4^{2}$, so this pair satisfies the condition.

Finally, assume that one of them, say $p$, is even and the other is odd. We then have $p=2$ and $2^{q+1}+q^{3}=a^{2}$ for some positive integer $a$. Write $q+1=2 b$ with $b$ a positive integer, then we have $2^{2 b}+q^{3}=a^{2}$, or equivalently,

$$
q^{3}=a^{2}-2^{2 b}=\left(a-2^{b}\right)\left(a+2^{b}\right).
$$

Both factors on the right must now be a $q$-power, say $a-2^{b}=q^{k}$ and $a+2^{b}=q^{l}$ with $l>k \geq 0$. Both factors are divisible by $q^{k}$, so their difference is also divisible by it. Thus $q^{k} \mid 2 \cdot 2^{b}=2^{b+1}$. But $q$ is an odd prime, so the only $q$-power that is a divisor of a power of two is 1. Therefore, $k=0$. We now get $q^{3}=a+2^{b}$ and $a-2^{b}=1$, so $q^{3}=\left(2^{b}+1\right)+2^{b}=2^{b+1}+1$. From this, it follows that

$$
2^{b+1}=q^{3}-1=(q-1)\left(q^{2}+q+1\right).
$$

However, $q^{2}+q+1 \equiv 1 \bmod 2$ and further, $q^{2}+q+1>1$, so it can never be a power of two. Contradiction.

We conclude that the only solution is $(p, q)=(2,2)$.