


i) Swap any two rows.
ii) Swap any two columns.
A chessboard matrix is a binary matrix where there are no two 0’s and no two 1’s who are adjacent to each other.
[ [1, 0], [0, 1] ] and [ [0, 1], [1, 0] ] are chessboard matrix whereas [ [1,0], [1, 1] ] isn’t.
The first line of the input contains ‘T’, denoting the number of test cases.
The first line of each test case contains an integer, ‘N’ denoting dimensions of the matrix.
Next ‘N’ lines contains, N space-separated integers MAT[i][j].
For each test case, print the minimum number of operations to convert the given matrix into a chessboard matrix.
Don't print anything it has already been taken care of. Just implement the given function.
1 <= T <= 3
1 <= N <= 3000
0 <= MAT[i][j] <= 1
Time Limit: 1sec
Explanation:
Algorithm is as follows: