Example: 39 passengers enter 4 garages, with no garage being empty. How many ways are there to distribute the passengers?
Let $A_{i}$ represent the set of allocation methods where the $i$-th compartment is empty $(1 \leqslant i \leqslant 4)$, and $I$ represent the set of all allocation methods, then
$$
\begin{array}{c}
|I|=4^{9},\left|A_{i}\right|=3^{9}(1 \leqslant i \leqslant 4), \\
\left|A_{i} \cap A_{j}\right|=2^{9}(1 \leqslant i<j \leqslant 4), \\
\left|A_{i} \cap A_{j} \cap A_{k}\right|=1(1 \leqslant i<j<k \leqslant 4), \\
\left|A_{1} \cap A_{2} \cap A_{3} \cap A_{4}\right|=0 .
\end{array}
$$

By the principle of inclusion-exclusion,
$$
\begin{aligned}
& \left|\left(A_{1} \cup A_{2} \cup A_{3} \cup A_{4}\right)^{\prime}\right| \\
= & 4^{9}-C_{4}^{1} \times 3^{9}+C_{4}^{2} \times 2^{9}-C_{4}^{3} \times 1+C_{4}^{4} \times 0 \\
= & 186480,
\end{aligned}
$$

which means there are 186480 allocation methods where no compartment is empty.