#include <cstdio>
#include <algorithm>
const int N = 2000;
int n;
char a[N][N];
int l, r, u, d;
int k;
int ai, aj, bi, bj;
char read_char()
{
int c = getchar();
while (c == ' ' || c == '\n' || c == '\r')
c = getchar();
return static_cast<char>(c);
}
int main()
{
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
scanf("%d", &n);
l = n - 1, r = 0;
u = n - 1, d = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
a[i][j] = read_char();
if (a[i][j] == '#')
{
u = std::min(u, i);
d = std::max(d, i);
l = std::min(l, j);
r = std::max(r, j);
}
}
}
if (a[u][l] == '#' && a[d][r] == '#')
{
for (k = 0; k < n; k++)
{
if (u + k >= n || a[u + k][l] != '#')
break;
if (l + k >= n || a[u][l + k] != '#')
break;
if (d - k < 0 || a[d - k][r] != '#')
break;
if (r - k < 0 || a[d][r - k] != '#')
break;
}
ai = u;
aj = l;
bi = d - k + 1;
bj = r - k + 1;
}
else
{
for (k = 0; k < n; k++)
{
if (u + k >= n || a[u + k][r] != '#')
break;
if (r - k < 0 || a[u][r - k] != '#')
break;
if (d - k < 0 || a[d - k][l] != '#')
break;
if (l + k >= n || a[d][l + k] != '#')
break;
}
ai = u;
aj = r - k + 1;
bi = d - k + 1;
bj = l;
}
printf("%d\n", k);
printf("%d %d\n", ai + 1, aj + 1);
printf("%d %d", bi + 1, bj + 1);
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCmNvbnN0IGludCBOID0gMjAwMDsKCmludCBuOwpjaGFyIGFbTl1bTl07CmludCBsLCByLCB1LCBkOwppbnQgazsKaW50IGFpLCBhaiwgYmksIGJqOwoKY2hhciByZWFkX2NoYXIoKQp7CglpbnQgYyA9IGdldGNoYXIoKTsKCgl3aGlsZSAoYyA9PSAnICcgfHwgYyA9PSAnXG4nIHx8IGMgPT0gJ1xyJykKCQljID0gZ2V0Y2hhcigpOwoKCXJldHVybiBzdGF0a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