8. 10 students stand in a row, and a red, yellow, or blue hat is to be given to each student. It is required that each color of hat must be present, and the hats of adjacent students must be of different colors. Then the number of ways to distribute the hats that meet the requirements is $\qquad$ kinds.
8. 1530.

Generalize to the general case.
Let the number of ways to arrange $n$ students according to the given conditions be $a_{n}$. Then
$$
\begin{array}{l}
a_{3}=6, a_{4}=18, a_{n+1}=2 a_{n}+6(n \geqslant 3) . \\
\text { Hence } a_{n+1}+6=2\left(a_{n}+6\right) \\
\Rightarrow a_{n}=\left(a_{3}+6\right) \times 2^{n-3}-6 \\
\Rightarrow a_{10}=12 \times 2^{7}-6=1530 .
\end{array}
$$