You are given an matrix with and values. You can swap any two adjacent rows of the matrix.
Your goal is to have all the values in the matrix below or on the main diagonal. That is, for each where , there must be no values in row that are to the right of column .
Return the minimum number of row swaps you need to achieve the goal.
输入格式
The first line of input gives the number of cases, . test cases follow.
The first line of each test case has one integer, . Each of the next lines contains characters. Each character is either or .
输出格式
For each test case, output
Case #X: K
where is the test case number, starting from , and is the minimum number of row swaps needed to have all the values in the matrix below or on the main diagonal.
You are guaranteed that there is a solution for each test case.