12. Let the set $M=\{1,2, \cdots, 10\}$,
$$
\begin{aligned}
A= & \{(x, y, z) \mid x, y, z \in M, \text { and } \\
& \left.9 \mid\left(x^{3}+y^{3}+z^{3}\right)\right\} .
\end{aligned}
$$

Then the number of elements in set $A$ is $\qquad$
12.243.

Notice that,
when $x \equiv 1(\bmod 3)$, $x^{3} \equiv 1(\bmod 9)$;
when $x \equiv 2(\bmod 3)$, $x^{3} \equiv-1(\bmod 9)$;
when $x \equiv 0(\bmod 3)$, $x^{3} \equiv 0(\bmod 9)$.
Thus, for $x \in \mathbf{Z}$, we have
$$
x^{3} \equiv 0,1,-1(\bmod 9) \text {. }
$$

To make $9 \mid \left(x^{3}+y^{3}+z^{3}\right)$, it is necessary that $x, y, z$ are all congruent to 0 modulo 3, or $x, y, z$ are pairwise incongruent modulo 3.
Therefore, the number of elements in set $A$ is
$$
3^{3}+\mathrm{A}_{3}^{3} \times 3 \times 3 \times 4=243 \text {. }
$$