Question: $n$ persons are to be allocated to $q$ distinct rooms. Find the number of ways that this can be done if only $m$ of the $q$ distinct rooms have exactly $k$ persons each, where $1\le m\le q$ and $mk\le n$.
My attempt:
$$\binom{q}{m}\cdot\binom{n}{mk}\frac{(mk)!}{(k!)^mm!}\cdot m!\cdot(*)$$
First I selected $m$ rooms out of $q$ in which to arrange the $m\times k$ people, then I just selected $m$ groups of $k$ people from the $mk$ people selected out the total $n$ people, which I then arranged into the $m$ selected rooms. $^*$At this point $n-mk$ people are still left to be arranged in $q-m$ rooms in such a way that in none of those rooms there are $k$ people since the question explicitly states that "$\textbf{only}$ $m$ of the $q$ rooms". This is where I am getting stuck...
Source of the question is "Principles and Techniques in Combinatorics by Chen Chuan-Chong and Koh Khee-Meng" and the given answer is
$$(-1)^m\frac{q!n!}{m!}\sum_{j=m}^{q}(-1)^j\frac{(q-j)^{n-kj}}{(k!)^j(n-kj)!(j-m)!(q-j)!}$$
numerically plugging the following values $(n,q,m,k)=(15,7,4,3)$, we can quite clearly see that this set of values will give valid cases, just for the sake of argument, put $3$ persons each in first $4$ rooms and then the remaining $3$ persons be put into any $3$ of left rooms, with each room holding $1$ person. So, this will be a valid case, but on putting these values in the given answer formula, it makes no sense as there is negative factorial generated in the denominator, does that mean the given answer is wrong?
For the formula to make sense, $n \ge qk$, but this is as shown above, not a necessary condition to get valid cases.