Positive Closure or Kleene Closure can be described as the set of finite-length strings that can be generated by concatenating arbitrary elements of a set of strings, allowing the use of the same element multiple times. In case of numbers, it means all possible numbers generated from selected digits. Given the number of available digits from to , sum all the numbers that can be formed as positive closures from those digits.
For example,
Suppose we can use up to two digits of and one digit of . There are exactly distinct numbers that can be constructed using these digits: , , , , , , , . The sum of all those numbers is .
The first line of input contains an integer (T \leq 500) denoting the number of testcases. Each testcase contains nine integers P_i (0 \leq P_i \leq 9) denoting the number of available digits for each digit (for i = 1..9).
For each test case, output a line in the format Case #x: M, where is the case number (starting from ) and is the sum of all possible numbers generated from the available digits. Output the result modulo .
Example 1