#include<iostream>
using namespace std;
int n;
int a[2056][2056];
int wi=0,wj=0;
bool t=0,s=0;
void inp()
{
    cin>>n;
    for (int i=0;i<n;i++) for (int j=0;j<n;j++) cin>>a[i][j];
}
/*
void showSq(int l, int i, int j)
{
    for (int I=i;I<i+l;I++) {for (int J=j;J<j+l;J++) cout<<a[I][J]<<' ';cout<<endl;}
}
*/
bool isSol (int l, int i, int j)
{
    t=0;
    s=0;
    for (int J=j;J<j+l;J++)
        {
    if (a[i][J]==a[i-1][J]) {wi=i;wj=J;t=true;return 0;}
    if (a[i+l-1][J]==a[i+l][J]) {wi=i+l-1;t=true;wj=J;return 0;}
        }
    for (int I=i;I<i+l;I++)
        {
    if (a[I][j]==a[I][j-1]) {wi=I;wj=j;s=true;return 0;}
    if (a[I][j+l-1]==a[I][j+l]) {wi=I;wj=j+l-1;s=true;return 0;}
        }
 //   showSq(l,i,j);
    return 1;
}
int main()
{
    inp();
    for (int s=n-2;s>1;s-=2){ for (int i=1;i+s-1<n-1;i++) for (int j=1;j+s-1<n-1;j++)
    {
        if (isSol(s,i,j)) {cout<<s<<' '<<i+1<<' '<<j+1<<endl;return 0;}
        else
            {
                if (t) j=wj;
                else if (s) {i=wi-1;break;}
            }
    }
    wi=0;
    wj=0;
    }
    return 0;
}
