Mini Sudoku X is played on a 6 × 6 grid of digits. The grid is a correct solution when every one of these groups holds each digit from 1 to 6 exactly once:
The grid below is a correct solution. The cells on the two diagonals are shaded.

Read a grid of 36 digits and decide whether it is a correct solution.
The first line has a positive integer T (T≤100000), the number of test cases. The test cases follow.
Each test case is six lines, and each line has six 1-digit integers separated by a space. A 1-digit integer is not always between 1 and 6, and a grid that holds a digit outside that range is not a correct solution.
For each test case print one line of the form Case#x: M, where x is the case number starting from 1, and M is 1 when that test case is a correct solution and 0 when it is not. There is no space between Case and #.