Example 2.6 Let $g(m, n)$ denote the number of different ways to distribute $m$ distinct items to $n (m \geqslant n)$ people such that each person receives at least one item. Find the counting formula for $g(m, n)$.
Let $S$ denote the set of all different ways to distribute $m$ distinct items to $n (m \geqslant n)$ people, then $|S|=n^{m}$. Let $s \in S$, if in the distribution method $s$, the $i$-th person $(1 \leqslant i \leqslant n)$ does not receive any item, then we say $s$ has property $a_{i}$. For any $k (1 \leqslant k \leqslant n)$ positive integers $i_{1}, i_{2}, \cdots, i_{k}\left(1 \leqslant i_{1}<i_{2}<\cdots<i_{k} \leqslant n\right)$, let $N\left(a_{i_{1}} a_{i_{2}} \cdots a_{i_{k}}\right)$ denote the number of elements in $S$ that simultaneously have properties $a_{i_{1}}, a_{i_{2}}, \cdots, a_{i_{k}}$, then $N\left(a_{i_{1}} a_{i_{2}} \cdots a_{i_{k}}\right)$ is equal to the number of different ways to distribute $m$ distinct items to the $n-k$ people excluding the $i_{1}, i_{2}, \cdots, i_{k}$ people, so
$$
N\left(a_{i_{1}} a_{i_{2}} \cdots a_{i_{k}}\right)=(n-k)^{m} .
$$

By the principle of inclusion-exclusion, the number of elements in $S$ that do not have any of the properties $a_{1}, a_{2}, \cdots, a_{n}$, i.e., the number of different distribution methods we seek, is
$$
\begin{aligned}
g(m, n) & =|S|+\sum_{k=1}^{n}(-1)^{k} \sum_{1 \leqslant i_{1}<i_{2}<\cdots<i_{k} \leqslant n} N\left(a_{i_{1}} a_{i_{2}} \cdots a_{i_{k}}\right) \\
& =n^{m}+\sum_{i=1}^{n}(-1)^{k}\binom{n}{k}(n-k)^{m} \\
& =\sum_{k=0}^{n-1}(-1)^{k}\binom{n}{k}(n-k)^{m} \\
& =\sum_{k=1}^{n}(-1)^{n-k}\binom{n}{k} k^{m} .
\end{aligned}
$$