So I encountered a certain problem when studying generating functions that I seem to be unable to fully solve.
The problem is as follows:
Carol is collecting money from her cousins to have a party for her aunt. If eight of the cousins promise to give 2, 3, 4, or 5 dollars each, and two others each give 5 or 10 dollars, what is the total number of ways Carol can collect exactly 40 dollars?
The solution is the coefficient of the $x^{40}$ term in the generating function
$(x^2 + x^3 + x^4 + x^5)^8(x^5+x^{10})^2$
which may be simplified to finding the coefficient of the $x^{14}$ term in
$(1+x+x^2+x^3)^8(1+x^5) = (\frac{1-x^4}{1-x})^8(1+2x^5+x^{10}) = (1-x^4)^8(1-x)^{-8}(1+2x^5+x^{10})$
This is where I am stuck. To find the coefficient I know that I am suppose to find all possible combinations of how $x^{14}$ can be created by evaluating the polynomial. This would be done quite easily if only the first term $(1-x^4)^8(1-x)^{-8}$ would exist but how I am suppose to do this with the additional term $(1+2x^5+x^{10})$ present? I.e how do I evaluate the different combinations $x^{14}$ may be created and the find the coefficient with the second term present?
There is a solution given in the book, but I do not understand the principle behind it.

We have $1+2x^5+x^{10}$ and also two other complicated factors:
$$(1-x)^{-8}\quad=\quad1+{-8 \choose 1}(-x)+{-8 \choose 2}(-x)^2+\dots+{-8 \choose 4}(-x)^4+{-8 \choose 5}(-x)^5+{-8 \choose 6}(-x)^6+\dots+{-8 \choose 9}(-x)^{9}+{-8 \choose 10}(-x)^{10}+\dots{-8 \choose 14}(-x)^{14}+\dots,$$
$$(1-x^4)^8\quad=\quad1-{8 \choose 1}x^4+{8 \choose 2}x^8-{8 \choose 3}x^{12}+\dots.$$
For $(1-x)^{-8}$, I have shown only the nine factors that are usable for our purpose. For each of these nine, in order:
take $x^{10}$ from the first factor; take the $x^4$ term from the third factor.
take $2x^{5}$ from the first factor; take the $x^8$ term from the third factor.
take $1$ from the first factor; take the $x^{12}$ term from the third factor.
take $x^{10}$ from the first factor; take the $1$ term from the third factor.
take $2x^{5}$ from the first factor; take the $x^4$ term from the third factor.
take $1$ from the first factor; take the $x^8$ term from the third factor.
take $2x^{5}$ from the first factor; take the $1$ term from the third factor.
take $1$ from the first factor; take the $x^4$ term from the third factor.
take $1$ from the first factor; take the $1$ term from the third factor.