18 Let $a, b, c, d, m, n \in \mathbf{N}, a^{2}+b^{2}+c^{2}+d^{2}=1989, a+b+c+d=m^{2}$, and the largest of $a, b, c, d$ is $n^{2}$, determine and prove the values of $m, n$.

Determine and prove the values of $m, n$.
18 By the Cauchy-Schwarz inequality, we have
$$
a+b+c+d \leqslant 2 \sqrt{1989}a^{2}+b^{2}+c^{2}+d^{2},
$$

so \( m^{2}=49 \) or 81. Without loss of generality, assume
$$
a \leqslant b \leqslant c \leqslant d=n^{2},
$$

If \( m=49 \), then
$$
(49-d)^{2}=(a+b+c)^{2}>a^{2}+b^{2}+c^{2}=1989-d^{2}.
$$

Thus,
$$
d^{2}-49 d+206>0,
$$

which implies \( d>44 \) or \( d \leqslant 4 \). But
$$
45^{2}>1989>d^{2},
$$

so \( d>22 \), hence \( m^{2} \neq 49 \). Therefore, \( m^{2}=81, m=9 \),
$$
a+b+c+d=81.
$$

By the Cauchy-Schwarz inequality, we have
$$
3\left(a^{2}+b^{2}+c^{2}\right) \geqslant(a+b+c)^{2},
$$

thus
$$
3\left(1989-d^{2}\right) \geqslant(81-d)^{2},
$$

simplifying to
$$
2 d^{2}-81 d+297 \leqslant 0,
$$

and further
$$
\begin{array}{c}
2 d^{2}-81 d0) .
\end{array}
$$

From the given conditions, we derive
$$
\begin{array}{c}
p+q+r=19, \\
p^{2}+q^{2}+r^{2}=439,
\end{array}
$$

and
$$
(p+q+r)^{2}>p^{2}+q^{2}+r^{2},
$$

which is a contradiction. Therefore, \( n^{2}=36, n=6 \). It is not difficult to find
$$
a=12, b=15, c=18, d=36.
$$