Check whether each completed 9x9 grid has digits 1 to 9 exactly once in every row, column, and 3x3 box.
Easy3MatrixHash mapInterviewNo attempts yetTime limit5sMemory limit512 MBSudoku is a single player number puzzle. You fill a 9x9 grid with digits so that every row, every column, and each of the nine non-overlapping 3x3 sub-grids holds each digit from 1 to 9 exactly once. A puzzle starts partly filled and usually has one solution.


You are given a completed N2×N2 Sudoku grid. Decide whether it is a valid solution. A valid solution meets all three conditions:
Uniqueness does not matter here. Only check whether the given grid is a valid solution.
The first line holds the number of test cases, T. T test cases follow. Each test case starts with an integer N. The next N2 lines describe a completed Sudoku grid, and each of those lines holds exactly N2 integers. Every integer in the input is positive and less than 1000.
Limits
For each test case, print one line in the form "Case #x: y", where x is the test case number starting from 1, and y is Yes if the grid is a valid solution or No if it is not. The judge is case sensitive, so yes and no are not accepted.