import java.util.Scanner;
class Solution {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
for (int testCase = 1; testCase <= 10; testCase++) {
int n = sc.nextInt();
char arr[][] = new char[8][8];
for (int i = 0; i < 8; i++) {
String temp = sc.next();
arr[i] = temp.toCharArray();
}
int result = 0;
for (int i = 0; i < 8; i++) {
for (int j = 0; j <= 8 - n; j++) {
boolean row = true;
for (int k = 0; k < n / 2; k++) {
if (row && arr[i][j + k] != arr[i][j + n - 1 - k]) {
row = false;
}
}
if (row) {
result++;
}
}
}
for (int i = 0; i <= 8 - n; i++) {
for (int j = 0; j < 8; j++) {
boolean col = true;
for (int k = 0; k < n / 2; k++) {
if (col && arr[i + k][j] != arr[i + n - 1 - k][j]) {
col = false;
}
}
if (col) {
result++;
}
}
}
System.out.printf("#%d %d\n", testCase, result);
}
}
}
찾아야할 회문의 길이 n을 가지고 가로기준, 세로기준으로 3중 for문을 2번 반복
ex) 예를 들어 가로row
기준이라면 arr[i][j]
에서 + k, arr[i][j + n - 1]
에서 -k 한것들을 서로 같은지 비교
그후 boolean 값이 true면 result값을 증가시켜 출력