Problem: You are given a matrix with rows (numbered from to ) and columns (numbered from to ). A number is written in the cell belonging to the -th row and the -th column, each number is either or .
A chip is initially in the cell , and it will be moved to the cell . During each move, it either moves to the next cell in the current row, or in the current column (if the current cell is , then after the move it can be either or ). The chip cannot leave the matrix.
Consider each path of the chip from to . A path is called palindromic if the number in the first cell is equal to the number in the last cell, the number in the second cell is equal to the number in the second-to-last cell, and so on.
Your goal is to change the values in the minimum number of cells so that every path is palindromic.
Input Format: The first line contains one integer () — the number of test cases.
The first line of each test case contains two integers and () — the dimensions of the matrix.
Then lines follow, the -th line contains integers , , ..., ().
Output Format: For each test case, print one integer — the minimum number of cells you have to change so that every path in the matrix is palindromic.
Note: The resulting matrices in the first three test cases: