Example 1.28 Use $m(m \geqslant 2)$ colors to paint a $1 \times n$ chessboard, with each cell painted one color. Let $h(m, n)$ denote the number of ways to paint such that adjacent cells have different colors and all colors are used. Find the counting formula for $h(m, n)$. s is not from the beginning.
Solution: Using $m$ colors to paint a $1 \times n$ chessboard, each cell is painted with one color and adjacent cells must have different colors. The number of ways to paint the chessboard is $m(m-1)^{n-1}$. Among these, the number of ways to use exactly $k(2 \leqslant k \leqslant m)$ colors is $\binom{m}{k} h(k, n)$. By the principle of addition, we have
$$
m(m-1)^{n-1}=\sum_{k=2}^{m}\binom{m}{k} h(k, n) .
$$

By the binomial inversion formula, we finally see the flavor of the principle of inclusion-exclusion. It is the same idea.
$$
h(m, n)=\sum_{k=2}^{m}(-1)^{m-k}\binom{m}{k} \cdot k(k-1)^{n-1} .
$$