Imagine you have a padlock, which is a combination lock consisting of N dials, set initially to a random combination. The dials of the padlock are of size D, which means that they can have values between 0 and D−1, inclusive, and can be rotated upwards or downwards. They are also ordered from left to right, with the leftmost and rightmost dials at positions 1 and N, respectively. The padlock can be unlocked by setting the values of all its dials to 0.
You can perform zero or more operations of this kind:
The series of operations must satisfy the following condition:
Example of a valid sequence of operations to unlock a padlock with initial combination \[1,1,2,2,3,3]:
The following are some operations that cannot be performed:
The goal for you is to output the minimum number of valid operations needed to make all dials in the padlock set to 0.
The first line of the input contains the number of test cases, T. T test cases follow.
Each test case consists of two lines.
The first line of each test case contains two integers N and D, representing the number of dials in the padlock and the size of the dials, respectively.
The second line of each test case contains N integers V_1,V_2,…,V_N, where the i-th integer represents the value of the i-th dial in the initial combination of the padlock.
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the minimum number of operations needed to unlock the padlock as described in the statement.