12. (IMO-20-1) The last three digits of the numbers $1978^{n}$ and $1978^{m}$ are equal. Find the positive integers $n$ and $m$ such that $n+m$ is minimized, where $n>m \geqslant 1$.
From the given, we have
$$
\begin{array}{l}
1978^{m}-1978^{m}=1978^{m}\left(1978^{n-m}-1\right) \\
=2^{m} \times 989^{m} \times\left(1978^{m}-1\right) \\
\equiv 0\left(\bmod 10^{3}\right) .
\end{array}
$$

Since
$$
10^{3}=2^{3} \times 5^{3},
$$

and $989^{m}$ and $1978^{\mathrm{m}}-1$ are both odd, it follows that $m \geqslant 3$. Also, 5 is coprime with $2^{m}$ and $989^{m}$, so
$$
1978^{n-m}-1 \equiv 0\left(\bmod 5^{3}\right) \text {. }
$$

That is, $1978^{n-m} \equiv 1(\bmod 125)$.
Thus, $3^{n-m} \equiv 1978^{\mathrm{n}-\mathrm{m}} \equiv 1(\bmod 25)$.
Using the method from Example 10 (now classifying by $\bmod 4$), we can derive from $3^{n-m} \equiv 1(\bmod 5)$ that
$$
n-m=4 k \text {. }
$$

Thus, $3^{4 k}=81^{k} \equiv 1 \quad(\bmod 25)$.
That is, $(80+1)^{\mathbf{k}}=1+k \times 80+C_{\mathbf{k}}{ }^{2} \times 80^{2} \equiv 1$
$(\bmod 25)$. Therefore, (since $25 \mid 80^{2}$) it is easy to see that $5 \mid k$. From (2) we get
$$
\begin{aligned}
1 \equiv 1978^{4 k}= & (3+1975)^{4 k} \equiv 3^{4 k}+4 k \\
& \times 3^{k-1} \times 1975 \equiv 3^{4 k}(\bmod 125) .
\end{aligned}
$$

That is, $1 \equiv 3^{4 k}=81^{k} \equiv 1+k \times 80+\frac{k(k-1)}{2}$
$$
\times 80^{2}=1+80 k(\bmod 125) \text {. }
$$
(Please note that $5 \mid \boldsymbol{k}$).
Thus, $125|80 k, 25| k$. Therefore, $k$ is at least 25, and $n-m$ is at least $4 \times 25=100$.
$$
\begin{array}{l}
n+m=(n-m)+2 m \\
\geqslant 100+2 \times 3=106 .
\end{array}
$$

Hence, the minimum value of $n-m$ is 106 (the above derivation can show that (1) holds in this case).