Inversions Organize
시간 제한20초메모리 제한1024 MB
I와 O로 이루어진 2N x 2N 격자에서 위아래 절반의 I 개수와 좌우 절반의 I 개수를 같게 만들기 위해 뒤집어야 하는 최소 칸 수를 구한다.
문제
After the troubles with printing advertising for IO two years ago, the marketing team of the conference decided to use an interactive installation. It consists of a matrix of rows and columns of touchscreens. Each touchscreen can display either an uppercase I or an uppercase O. When one of the screens is touched, it switches the letter it displays to the one it was not displaying right before the touch occurred.
You are looking at one of those installations, and find it to be disorganized. You want to change some of the letters such that the top rows show the same number of letter I's as the bottom rows, and at the same time, the leftmost columns show the same number of letter I's in total as the rightmost columns.

For example, in the left picture above, . The top rows show letter I's in total, while the bottom rows show . On the other hand, both the leftmost columns and the rightmost columns show letter I's. By touching the two highlighted screens we can change the state to that shown in the right picture, which shows letter I's in the top columns and in the bottom columns, and also maintains the balance between the left and right sides.
Given the state of the installation, can you find the minimum number of letter changes needed to achieve your organizational goal?
입력
The first line of the input gives the number of test cases, . test cases follow. Each test case starts with a line containing a single integer , half the number of rows and columns of the matrix. Then, lines follow. The -th of these contains a string of characters . is the letter currently displayed in the screen in the -th row and -th column of the matrix.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the minimum number of touches required to make the installation simultaneously display the same number of letter I's in its top and bottom halves, and the same number of letter I's in its left and right halves.
제한
- .
- is either an uppercase
Ior an uppercaseO, for all .
힌트
Sample Case #1 is the one explained in the statement. Not touching anything does not work, and a single touch would leave an odd number of letters I in total, so the result cannot be balanced. It is explained in the statement how it can be balanced with two touches (there are other ways).
In Sample Case #2, changing the top left corner to O leaves no letter I, so all halves have the same amount ().
In Sample Case #3, the installation is already organized according to your requirements, so no touch is needed.