You are given a square matrix of size n (it will be an odd integer). Rows are indexed 0 to n-1 from top to bottom and columns are indexed 0 to n-1 form left to right. Matrix consists of only '*' and '.'. '*' appears only once in the matrix while all other positions are occupied by '.'
Your task is to convert this matrix to a special matrix by following any of two operations any number of times.
-
you can swap any two adjecent rows, i and i+1 (0<= i < n-1)
-
you can swap any two adjecent columns, j and j+1 (0<= j < n-1)
Special Matrix is one which contain '*' at middle of matrix. e.g following is size 7 special matrix
....... ....... ....... ...*... ....... ....... .......
Output no of steps to convert given matrix to special matrix.
INPUT:
first line contains t, no of test cases first line of each test case contains n (size of matrix) followed by n lines containing n characters each.
OUTPUT:
print t lines, each containing an integer, the answer for the test case.
Constraints:
0 <= t <= 50
3 <= n <= 20
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor