//* Problem  : H: Stake Your Claim
//* Contest  : ECNA-2006
//* Type     : Solution
//* Date     : 2008.08.04
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

typedef pair <int,int> PIII;
typedef vector <int> VI;
typedef vector <vector<int> > VVI;
typedef vector <pair<int,int> > VPII;
typedef vector <vector<pair<int,int> > > VVPII;

#define int64 long long
#define PI (2.0 * acos(0.0))
#define MP make_pair
#define PB push_back
#define SZ(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < (int)n; i++)
#define FORSZ(i, a) FOR(i, SZ(a))
#define FORE(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(a); i >= int(b); i--)
#define INF 1000000000
#define INFL 1000000000000000000LL
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()

inline int si(){int tt; scanf("%d", &tt); return tt;}

#define D 10000

vector <string> a;

int res_x, res_y, res, n;

vector<map <string, int> > mp;

vector <string> aa;

int who;

int dfs(int x, int y, int val)
{
	if (aa[x][y] != val) return 0;
	aa[x][y] = '#'; 
	int res = 1;
	if (x) res += dfs(x - 1, y, val);
	if (y) res += dfs(x, y - 1, val);
	if (x != n-1) res += dfs(x + 1, y, val);
	if (y != n-1) res += dfs(x, y + 1, val);
	return res;
}

int check(vector <string> a, int pl)
{
	aa = a;
	int maxx[2] = {0,0};
	FOR(i,n)FOR(j,n)
		if (aa[i][j] != '#')
		{
			int v = a[i][j] - '0';
			maxx[v] = max(maxx[v], dfs(i,j, v+'0'));
		}
//	printf("Check = %d\n", maxx[pl] - maxx[1-pl]);
/*	printf("%s\n", a[0].c_str());
	printf("%s\n", a[1].c_str());
	printf("%s\n", a[2].c_str());
	printf("%s\n", a[3].c_str());
	printf("%d\n", maxx[who] - maxx[1-who]);
*/	return maxx[who] - maxx[1-who];
}

int move(vector <string> a, int left, int player)
{
	if (!left) 
		return check(a, player);
	string sss = "";
	FOR(i, n)sss+=a[i];
	if (!mp[player][sss])
	{
		int res = player == who ? -INF : INF;
		{
			FOR(i,n)FOR(j,n) if (a[i][j] == '.')
			{
				vector <string> t(a);
				t[i][j] = player + '0';
				if (player == who)
					res = max(res, move(t, left - 1, 1 - player));
				else
					res = min(res, move(t, left - 1, 1 - player));
			}
		}
		mp[player][sss] = res + 120000;
	}
	return mp[player][sss] - 120000;
}

void solve()
{
//	mp.assign(2, map<string, int>());
	res = -INF;
	int left = 0, c0 = 0, c1 = 0;
	FOR(i,n)FOR(j,n) 
	{
		left += a[i][j] == '.';
		c0 += a[i][j] == '0';
		c1 += a[i][j] == '1';
	}
	if (c0 > c1) who = 1; else who = 0;
	FOR(i,n) FOR(j,n) if (a[i][j] == '.')
	{
			vector <string> t(a);
			t[i][j] = '0'+who;
			int tt = move(t, left - 1, 1-who);
			if (tt > res)
			{
				res = tt;
				res_x = i;
				res_y = j;
			}
	}

}

void result()
{
	printf("(%d,%d) %d\n", res_x, res_y, res);
}

int main()
{
#ifdef _DEBUG
	freopen("1064", "r", stdin);
	freopen("1064w", "w", stdout);
#endif
	mp.assign(2, map <string, int>());
	while (scanf("%d", &n) && n)
	{
		a.clear();
		FOR(i, n) {char s[100]; scanf("%s", s); a.PB(string(s));}
		solve();
		result();
	}
	return 0;
}

