SOLVE
LATER
There are \(T\) restaurants in bagel-world. The \(i^{th}\) restaurant serves \(n_i\) distinct kind of bagels. Being a foodie you visit all the restaurants and in \(i^{th}\) restaurant you order \(k_i\) bagels. You have to tell the number of ways the order can be placed in the \(i^{th}\) restaurant given that the count of any kind of bagel should always be less than \(P\). Two orders are considered different if there is atleast one kind of bagel whose count in the order is different. Since the answer can be large you have to output answer modulo \(P\) .
Note: \(P\) is a prime.
For the \(1^{st}\) restaurant, there are \(2\) kinds of bagels and the order consists of \(3\) bagels. All the possible ways to make the order are: \((0, 3), (1, 2), (2, 1) \text{ and } (3, 0)\). So the answer is \(4\) mod \(5\) \(i.e.\)\(4\)
Note: \((x, y)\) here represents that you order \(x\) bagels of first kind and \(y\) bagels of second kind.
For the \(2^{nd}\) restaurant \(5\) the possible ways are: \((0, 4), (1, 3), (2, 2), (3, 1) \text{ and } (4, 0)\). So the answer is \(5\) mod \(5\) \(i.e.\) \(0\)
For the \(3^{rd}\) restaurant the \(3\) possible ways are: \((2, 4), (3, 3), (4, 2)\). So the answer is \(3\) mod \(5\) \(i.e.\) \(3\)
Note: \((0, 6), (1, 5), (5, 1) \text{ and } (6, 0)\) are NOT valid orders as count of any kind of bagel is always less than \(P\) .
For the \(4^{th}\) restaurant there are \(19\) possible ways to order. So the answer is \(19\) mod \(5\) \(i.e.\) \(4\)