4. Given prime numbers $p$ and $q$ such that $p^{2}+3 p q+q^{2}$ is a perfect square of some integer. Then the maximum possible value of $p+q$ is $\qquad$ (Bulgaria)
4. 10 .

Let $p^{2}+3 p q+q^{2}=r^{2}\left(r \in \mathbf{Z}_{+}\right)$.
If $3 \nmid r$, then $r^{2} \equiv 1(\bmod 3)$.
If $p \neq 3$ and $q \neq 3$, then
$$
p^{2}+3 p q+q^{2} \equiv 2(\bmod 3),
$$

but $r^{2} \equiv 1(\bmod 3)$, a contradiction.
Thus, without loss of generality, assume $p=3$.
Hence $q^{2}+9 q+9=r^{2}$
$$
\begin{array}{l}
\Rightarrow 4 q^{2}+36 q+36=4 r^{2} \\
\Rightarrow(2 q-2 r+9)(2 q+2 r+9)=45 .
\end{array}
$$

Since $r>0$, we consider two cases.
(1) $\left\{\begin{array}{l}2 q+2 r+9=15, \\ 2 q-2 r+9=3\end{array} \Rightarrow q=0\right.$, which is impossible.
(2) $\left\{\begin{array}{l}2 q+2 r+9=45 \\ 2 q-2 r+9=1\end{array} \Rightarrow q=7, r=11\right.$.

Therefore, $p+q=10$.