4. Let $A=\{a, b, c, d\}, B=\{1,2,3\}$. If the mapping $f: A \rightarrow B$, such that
$$
f(a)+f(b)+f(c)+f(d)=8,
$$

then the number of such mappings is ( ).
(A) 16
(B) 17
(C) 19
(D) 24
4.C.

Consider the number of integer solutions to $x_{1}+x_{2}+x_{3}+x_{4}=8\left(1 \leqslant x_{i} \leqslant 3, i=1,2,3\right.$, $4)$, which is equivalent to the number of integer solutions to $y_{1}+y_{2}+y_{3}+y_{4}=4\left(0 \leqslant y_{i} \leqslant 2\right.$, $i=1,2,3,4)$. It equals $\mathrm{C}_{7}^{3}-4 \mathrm{C}_{4}^{3}=19$.