Find the number of $n$-digit numbers composed of $1, 2, 3$ where each of $1, 2, 3$ appears at least once.
Let the set of all $n$-digit numbers composed of $1, 2, 3$ be denoted as $S$, then $|S|=3^{n}$. The set of $n$-digit numbers in $S$ that do not contain $i(i=1,2,3)$ is denoted as $A_{i}$. Then $\left|A_{i}\right|=2^{n}(i=1,2,3),\left|A_{i} \cap A_{j}\right|=$ $1(1 \leqslant i<j \leqslant 3),\left|A_{1} \cap A_{2} \cap A_{3}\right|=0$. By the principle of inclusion-exclusion, the number of $n$-digit numbers sought $\mid \bar{A}_{1} \cap$ $\bar{A}_{2} \cap \bar{A}_{3}|=| S|-| A_{1}|-| A_{2}|-| A_{3}|+| A_{1} \cap A_{2}|+| A_{2} \cap A_{3}|+| A_{1} \cap A_{3} \mid-$ $\left|A_{1} \cap A_{2} \cap A_{3}\right|=3^{n}-3 \cdot 2^{n}+3$.