P16473 [GKS 2013 #B] Sudoku Checker
Description
**Sudoku** is a popular single player game. The objective is to fill a $9 \times 9$ matrix with digits so that each column, each row, and all $9$ non-overlapping $3 \times 3$ sub-matrices contain all of the digits from $1$ through $9$. Each $9 \times 9$ matrix is partially completed at the start of game play and typically has a unique solution.
:::align{center}
 
:::
Given a completed $\mathbf{N^2} \times \mathbf{N^2}$ Sudoku matrix, your task is to determine whether it is a *valid* solution. A valid solution must satisfy the following criteria:
- Each row contains each number from $1$ to $\mathbf{N^2}$, once each.
- Each column contains each number from $1$ to $\mathbf{N^2}$, once each.
- Divide the $\mathbf{N^2} \times \mathbf{N^2}$ matrix into $\mathbf{N^2}$ non-overlapping $\mathbf{N} \times \mathbf{N}$ sub-matrices. Each sub-matrix contains each number from $1$ to $\mathbf{N^2}$, once each.
You don't need to worry about the uniqueness of the problem. Just check if the given matrix is a valid solution.
Input Format
The first line of the input gives the number of test cases, $T$. $T$ test cases follow. Each test case starts with an integer $N$. The next $N^2$ lines describe a completed Sudoku solution, with each line contains exactly $N^2$ integers. All input integers are positive and less than $1000$.
Output Format
For each test case, output one line containing "Case #x: y", where x is the case number (starting from $1$) and y is "Yes" (quotes for clarity only) if it is a valid solution, or "No" (quotes for clarity only) if it is invalid. Note that the judge is case-sensitive, so answers of "yes" and "no" will not be accepted.
Explanation/Hint
### Limits
$1 \le T \le 100$.
**Test set 1 - Visible**
$N = 3$.
**Test set 2 - Hidden**
$3 \le N \le 6$.