Sum of the Dice

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 128.0 MB

You have N dice; each has \(K\) faces numbered from \(1\) to \(K\). Now you have arranged the \(N\) dice in a line. You can rotate/flip any dice if you want. How many ways you can set the top faces such that the summation of all the top faces equals \(S\)?

Given \(N\), \(K\), and \(S\), you have to calculate the total number of ways.

Format

Input

Input starts with an in integer \(T (\le 25)\), denoting the number of test cases.

Each case contains three integers: \(N (1 \le N \le 1000)\), \(K (1 \le K \le 1000)\), and \(S (0 \le S \le 15000)\).

Output

For each case, print the case number and the result modulo \(10^8 + 7\).

Sample

Input Output
5
1 6 3
2 9 8
500 6 1000
800 800 10000
2 100 10
Case 1: 1
Case 2: 7
Case 3: 57286574
Case 4: 72413502
Case 5: 9

Source:

LightOJ - Dice (I)

Sylhet ICPC 2024 Collaborative Challenge: Episode 2

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
9
Start at
2024-10-30 08:45
End at
2024-10-30 12:45
Duration
4.0 hour(s)
Host
Partic.
18