

Problem J. Let Sudoku RotateTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1679 Accepted Submission(s): 867 Problem Description Sudoku is a logicbased, combinatorial numberplacement puzzle, which is popular around the world. In this problem, let us focus on puzzles with $16 \times 16$ grids, which consist of $4 \times 4$ regions. The objective is to fill the whole grid with hexadecimal digits, i.e. 0123456789ABCDEF, so that each column, each row, and each region contains all hexadecimal digits. The figure below shows a solved sudoku. Yesterday, Kazari solved a sudoku and left it on the desk. However, Minato played a joke with her  he performed the following operation several times. * Choose a region and rotate it by 90 degrees counterclockwise. She burst into tears as soon as she found the sudoku was broken because of rotations. Could you let her know how many operations her brother performed at least? Input The first line of the input contains an integer $T$ $(1 \le T \le 10 ^ 3)$ denoting the number of test cases. Each test case consists of exactly $16$ lines with $16$ characters each, describing a broken sudoku. Output For each test case, print a nonnegative integer indicating the minimum possible number of operations. Sample Input
Sample Output
Hint The original sudoku is same as the example in the statement. Source  
