import java.io.*;
import java.util.*;
class Solution {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int T = Integer.parseInt(br.readLine());
for (int test_case = 1; test_case <= T; test_case++) {
int N = Integer.parseInt(br.readLine());
int[][] crops = new int[N][N];
for (int i = 0; i < crops.length; i++) {
char[] c = br.readLine().toCharArray();
for (int j = 0; j < crops.length; j++) {
crops[i][j] = c[j] - '0';
}
}
int sum = 0;
int fix = (N + 1) / 2 - 1;
for (int i = 0; i < (crops.length + 1) / 2; i++) {
for (int j = 0; j < crops.length - i * 2; j++) {
if (i == 0) {
sum += crops[fix][j];
} else {
sum += crops[fix - i][i + j];
sum += crops[fix + i][i + j];
}
}
}
sb.append("#").append(test_case).append(" ").append(sum).append("\n");
}
System.out.println(sb);
br.close();
}
}