#include<stdio.h>
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};

char v[405][405];
int us[405][405], filln = 1;

int fill(int x, int y, int c){
	int ans = 1;
	us[x][y] = filln;
	for(int i = 0; i < 4; i++){
		int nx = x + dx[i], ny = y + dy[i];
		if(v[nx][ny] == c && us[nx][ny] < filln)
			ans += fill(nx, ny, c);
	}
	return ans;
}

int main(void){
	int t, m, n;
	scanf("%d%d%d ", &t, &m, &n);
	for(int i = 1; i <= m; i++)
		scanf("%s ", &v[i][1]);

	int best = 0, bestx, besty, cur;
	char bestc;
	for(int x = 1; x <= m; x++)
		for(int y = 1; y <= n; y++){
			cur = fill(x, y, v[x][y]);
			if(cur > best)
				best = cur, bestx = x, besty = y, bestc = v[x][y];
			if(t == 1)
				continue;
			for(int k = 0; k < 4; k++){
				int nx = x + dx[k], ny = y + dy[k];
				if(!v[nx][ny] || v[nx][ny] == v[x][y])
					continue;
				cur = fill(x, y, v[nx][ny]);
				filln++;
				if(cur > best)
					best = cur, bestx = x, besty = y, bestc = v[x][y];
			}
		}

	if(t == 1)
		printf("%d\n", best);
	else
		printf("%d %d\n%c\n", bestx, besty, bestc);
	return 0;
}