3. Determine all pairs $(p, m)$ consisting of a prime number $p$ and a positive integer $m$ for which

$$
p^{3}+m(p+2)=m^{2}+p+1 .
$$
3. All terms divisible by $p$ are brought to the left side. This gives $p^{3}+m p-p=$ $m^{2}-2 m+1$, or equivalently

$$
p\left(p^{2}+m-1\right)=(m-1)^{2} \text {. }
$$

Note that $m-1$ is non-negative by assumption. We see that $p$ is a divisor of $(m-1)^{2}$. Since $p$ is a prime number, $p$ is also a divisor of $m-1$. We write $m-1=k p$, where $k$ is a non-negative integer. Substituting gives: $p\left(p^{2}+k p\right)=k^{2} p^{2}$. Dividing both sides by $p^{2}$, we find $p+k=k^{2}$, or equivalently

$$
p=k(k-1) \text {. }
$$

Since $p$ is a prime number, one of the factors $k$ and $k-1$ must be equal to 1 (the case $k-1=-1$ is excluded). Since $k=1$ (and $k-1=0$) is not valid, the only remaining possibility is that $k-1=1$. We then find $k=2, p=2$ and $m=5$, so $(p, m)=(2,5)$ is the only possible solution. It is clear that this is indeed a solution.