Even More Dice

No attempts yetTime limit5sMemory limit512 MB

Problem

Carlisle's Casino has a new dice game that everyone is talking about. The player rolls nn dice, each with faces numbered 11 through mm, and has to hit the sum the dealer picks at random. For every sum the dealer calls, find all the rolls that add up to it.

Input

The first line contains one integer cc, the number of test cases. Each of the next cc lines contains three space separated integers nn, mm, and ss: the number of dice, the number of faces on each die, and the sum that must be rolled.

Output

For each test case, print the line Case x: first, where xx is the case number starting at 11.

Then print every combination of dice values that adds up to ss, one per line. All nn dice must be used. Write a combination with its values comma separated and wrapped in parentheses, arranged from least to greatest when read left to right, and print only one permutation of each combination. For n=3n = 3, (1,2,3) is correct while (2,3,1), (2,1,3), (3,1,2), (3,2,1), and (1,3,2) are not.

When more than one combination exists, print them in ascending lexicographic order. The combination with the smaller first value comes first, ties are broken by the second value, and so on. If the sum ss cannot be rolled, print only the Case x: line.

Constraints

  • 2n62 \le n \le 6
  • 3m123 \le m \le 12
  • 2s802 \le s \le 80