Task
Dorel, a 10th-grade student, has recently started experimenting with algorithms to place identical balls into boxes! He tried to analyze how many ways he can place the balls into the chosen boxes such that for a chosen constant , the algorithm he wrote on paper does not run indefinitely. His algorithm can be found written in pseudocode below:
pos ← 1
sum ← 0
while pos <= c:
while sum != k:
sum ← sum + nrbile[pos] + 1
pos ← pos + 1
sum ← 0
Task
For balls, boxes, and a constant , determine in how many ways we can place the balls in the boxes such that the algorithm presented above does not run indefinitely. As this number can be very large, Dorel asks you to find the result modulo .
Input data
The first line of the input file dorel.in
contains the number , which represents the number of tests. Then, on the next lines, there will be 3 numbers , and with the above-mentioned significance. The tests in the input are independent of each other.
Output data
In the file dorel.out
, numbers will be displayed on separate lines, where on line of the output will be the answer to the -th test modulo .
Constraints and clarifications
- According to the OJI regulations, the tests will be evaluated individually, so it is not necessary to pass all tests to receive points for the respective subtask.
# | Points | Constraints |
---|---|---|
1 | 20 | |
2 | 20 | |
3 | 5 | |
4 | 10 | |
5 | 10 | |
6 | 35 | No additional constraints. |
Example 1
dorel.in
6
3 3 3
1 5 6
10 10 10
5 8 1
10 2 4
961 423 346
dorel.out
4
5
43758
0
0
434187092
Explanation
For the case we have the following valid configurations:
For the case we have the following valid configurations: