import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int H = Integer.parseInt(st.nextToken());
int W = Integer.parseInt(st.nextToken());
char[][] grid = new char[H][W];
for (int i=0; i<H; i++) {
st = new StringTokenizer(br.readLine());
String S = st.nextToken();
for (int j=0; j<W; j++) {
grid[i][j] = S.charAt(j);
}
}
int count = 0;
for (int i=0; i<H; i++) {
int h1 = i;
for (int j=h1; j<H; j++) {
int h2 = j;
for (int l=0; l<W; l++) {
int w1 = l;
for (int k=w1; k<W; k++) {
int w2 = k;
for (int x = h1; x<h2; x++) {
for (int y = w1; y<w2; y++) {
if (grid[x][y] == grid[h1+h2-x][w1+w2-y]) {
count ++;
System.out.println(x + " " +y);
}
}
}
}
}
}
}
System.out.println(count);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: