12. (22 points) Find all pairs of positive integers $(m, n)$ that satisfy $1 \leqslant m^{n}-n^{m} \leqslant m n$.
12. First, prove two lemmas.

Lemma 1: $f(x)=\frac{\ln x}{x}$ is monotonically increasing on the interval $(0, \mathrm{e}]$ and monotonically decreasing on the interval $[\mathrm{e},+\infty)$.

Proof of Lemma 1: Note that $f^{\prime}(x)=\frac{1-\ln x}{x^{2}}$ is greater than 0 on the interval $(0, \mathrm{e})$ and less than 0 on the interval $(\mathrm{e},+\infty)$.
Lemma 2: When $x>0$, $\ln (1+x) < x$.

Proof of Lemma 2: For $x>0$, $f^{\prime}(x)=\frac{x}{1+x}>0$, hence $f(x)$ is monotonically increasing.
By $f(0)=0$, we get $x>\ln (1+x)$.
Lemmas 1 and 2 are proved.
According to Lemma 1, $m^{n}>n^{m} \Leftrightarrow \frac{\ln m}{m}>\frac{\ln n}{n}$.
Consider the following cases.
(1) $n=1, m \geqslant 2$.
$(m, n)$ all satisfy the condition.
(2) $m=2, n \geqslant 5$.
Let $g(x)=2^{x}-x^{2}-2 x (x \geqslant 5)$. Then $g^{\prime}(x)=2^{x} \ln 2-2 x-2>0$.
Since $g(5)=-3, g(6)=16$, the only $(m, n)$ that satisfies the condition is $(2,5)$.
(3) $m=3, n=2$.
It is easy to verify that $(3,2)$ satisfies the condition.
(4) $m \geqslant 3, n \geqslant m+1$.
Let $g(x)=m^{x}-x^{m}-m x$.
When $x \geqslant m+1$,
$$
\begin{array}{l}
g^{\prime}(x)=m^{x} \ln m-m x^{m-1}-m \\
>x^{m}-m x^{m-1}-m \geqslant x^{m-1}-m>0 .
\end{array}
$$

Then $g(x)$ is monotonically increasing.
Thus, $g(n) \geqslant g(m+1)$
$$
\begin{array}{l}
=m^{m+1}-(m+1)^{m}-m(m+1) \\
=m^{m}\left[m-\left(1+\frac{1}{m}\right)^{m}\right]-m(m+1) .
\end{array}
$$

When $m=3$, $g(m+1)=5$;
When $m \geqslant 4$, according to Lemma 2,
$$
g(m)>m^{m}-m(m+1)>0,
$$

there are no $(m, n)$ that satisfy the condition.
In summary, all positive integer pairs that satisfy the condition are
$$
\{(m, 1),(2,5),(3,2) \mid m \geqslant 2\} .
$$