The context of the problem is different but I'll try to describe using red and black balls.
Let say we have 5 boxes with red and black balls and we take one from each box. The number of ways to get only red balls is $r_1 \cdot r_2 \cdot r_3 \cdot r_4 \cdot r_5$ where r is the number of red balls in the each box. If we want to get exactly 3 red and 2 black balls the number of ways is the sum of 10 products $(r_1 \cdot r_2 \cdot r_3 \cdot b_4 \cdot b_5 ) + ( r_1 \cdot r_2 \cdot b_3 \cdot r_4 \cdot b_5 ) + \cdot \cdot \cdot + ( b_1 \cdot b_2 \cdot r_3 \cdot r_4 \cdot r_5)$.
Now I have a slightly different problem. Each box has red, black and some other balls that we don't know yet the color (red or black). The number of balls with unknown colors is $q$.
If we take one ball from each box and we want all to be red, the maximum number of possible ways now is $(r_1+q_1)(r_2+q_2)(r_3+q_3)$...since each unknown color can be red.
My question is what is the maximum number of ways to get 3 red and 2 black balls in the second version?
So, from all combinations of balls $N = (r_1+b_1+q_1)(r_2+b_2+q_2)\cdots(r_5+b_5+q_5)$, how many of them are candidates to have 3 red and 2 black balls?