12. (18 points) A school's mathematics interest group consists of $m$ students, and the school has arranged $n$ instructors to guide them. During one of the group's activities, each pair of students asks each other one question, each student asks each instructor one question, and each instructor asks the entire group one question. It is known that a total of 51 questions were asked, and all questions are distinct. Try to find the values of $m$ and $n$.


12. From the problem, we have
$$
\begin{array}{l}
m(m-1)+m n+n=51 \\
\Rightarrow m^{2}+(n-1) m+n-51=0 .
\end{array}
$$

Then $\Delta=(n-1)^{2}-4(n-51)$
$$
=n^{2}-6 n+205=(n-3)^{2}+196
$$

must be a perfect square.
Let $(n-3)^{2}+196=k^{2}\left(k \in \mathbf{N}_{+}\right)$. Then
$$
(n-3+k)(n-3-k)=-196 \text {, }
$$

where $n-3+k$ and $n-3-k$ have the same parity, and
$$
n-3+k \geqslant n-3-k \text {. }
$$

Thus $\left\{\begin{array}{l}n-3+k=2, \\ n-3-k=-98 ;\end{array}\right.$
or $\left\{\begin{array}{l}n-3+k=98, \\ n-3-k=-2 ;\end{array}\right.$
or $\left\{\begin{array}{l}n-3+k=14, \\ n-3-k=-14 .\end{array}\right.$
The above systems of equations have only one solution $(m, n)=(6,3)$ that satisfies the problem.