#include <iostream>
#include <fstream>
using namespace std;

#define MAX_N 499
#define MAX_M 499

int hasColor[27], color[27], type, m, n, colors, value,maxZones;
int pharm[MAX_N][MAX_M], temp[MAX_N][MAX_M], dimens[MAX_N][MAX_M], zone[MAX_N][MAX_M], zoneCNT;

int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };

int inter(int x, int y)
{
	return (1 <= x && x <= n && 1 <= y && y <= m);
}

ifstream f("pharm.in");
ofstream g("pharm.out");

void fill(int x, int y, int val)
{
	int xn, yn,k;
	temp[x][y] = 0;

	for (k = 0; k < 4; k++)
	{
		xn = x + dx[k];
		yn = y + dy[k];
		if (inter(xn, yn) && temp[xn][yn] == val)
		{
			value++;
			fill(xn, yn, temp[xn][yn]);
		}
	}
	dimens[x][y] = value;
	zone[x][y] = zoneCNT;
}


void readData()
{
	int i,j;
	char c;
	f >> type;
	f >> n >> m;
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= m; j++)
		{
			f >> c;
			if (!hasColor[c - 'a'])
			{
				colors++;
				color[c - 'a'] = colors;
				pharm[i][j] = colors;
				hasColor[c - 'a'] = 1;
			}
			else
			{
				pharm[i][j] = color[c - 'a'];
			}
		}
	}
}

void compute()
{
	int i, j, max = 0, x1, x2, y1, y2, cX, cY, nr;

	
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= m; j++)
		{
			temp[i][j] = pharm[i][j];
		}
	}

	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= m; j++)
		{
			if (temp[i][j])
			{
				zoneCNT++;
				value = 1;
				fill(i, j, temp[i][j]);
				if (value > max) max = value;
			}
		}
	}

	if (type == 1)
	{
		cout << max;
	}
	else
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= m; j++)
			{
				for (int k = 0; k < 3; k++)
				{
					if (inter(i + dx[k], j + dy[k]))
					{
						x1 = i + dx[k];
						y1 = j + dy[k];
						for (int l = k + 1; l < 4; l++)
						{
							if (inter(i + dx[l], j + dy[l]))
							{
								x2 = i + dx[l];
								y2 = j + dy[l];
								if (pharm[x1][y1] == pharm[x2][y2] && pharm[x1][y1] != pharm[i][j] && zone[x1][y1] != zone[x2][y2])
								{
									long count = dimens[x1][y1] + dimens[x2][y2];
									if (count>maxZones)
									{
										maxZones = count;
										cX = i;
										cY = j;
										nr = pharm[x1][y1];
									}
									else if (count == maxZones)
									{
										if (i < cX || (i == cX && j < cY))
										{
											cX = i;
											cY = j; 
											nr = pharm[x1][y1];
										}
									}
								}
							}
						}
					}
				}
			}
		}

		int col;

		for (i = 0; i < 26; i++)
		{
			if (nr == color[i]) col = i;
		}

		cout << cX << " " << cY << "\n" << (char)(col + 'a');
	}
}

int main()
{
	readData();
	compute();
	return 0;
}