#include<iostream>
using namespace std;


short a[2001][2001];
short pr[2001][2001]; // prime=3 second=1;
short pos[2001][2001];// vert= 0 hor=1;
short hertz[2001][2001];
short ci,cj,cw;
short n,m;
bool lock;

int bi,bj,si,sj,ti,tj,ei,ej;
int w;
void checkwall()
{
    //cout<<bi<<' '<<bj<<endl;
    if(w>cw){cw=w;ci=bi;cj=bj;}

}

void findwallleft()
{
    if(hertz[ti][bj]==1 || hertz[ti][bj]==5){
          //  cout<<"YES 4"<<endl;
        //    cout<<ti<<' '<<bj<<endl;
        int i,j;

        for(i=bi+1;i<ti;i++)
            if(hertz[i][bj]==2)lock=1;

        for(j=bj+1;j<tj;j++)
            if(hertz[ti][j]==4)lock=1;

           if(lock==0)checkwall();
            }
}

void findwalldown()
{

    int i;
    if(hertz[bi+w-1][sj]<3)
    {
    ti=bi+w-1; tj=sj;
   // cout<<"YES 3"<<endl;
   // cout<<ti<<' '<<tj<<endl;

    for(i=si+1;i<ti;i++)
        if(hertz[i][sj]==5)lock=1;

     if(lock==0)findwallleft();
     }
}
void findwallright()
{
    int j;
    for(j=bj+1;j<n;j+=2)
        if(hertz[bi][j]==2 || hertz[bi][j]==4)
        {
        w=sj-bj+1;
        si=bi;sj=j;
     //   cout<<"YES 2"<<endl;
      //  cout<<si<<' '<<sj<<endl;

      for(j=bj+1;j<sj;j++)
        if(hertz[bi][j]==1)lock=1;
        if(lock==0)findwalldown();
        }

}

int main()
{

    cin>>n;
    short i,j;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        {
            cin>>a[i][j];
            pr[i][j]=4;

            if(a[i][j]==a[i-1][j])
            {
                pos[i][j]=0;
                pos[i-1][j]=0;
                pr[i][j]=1;
            }

            if(a[i][j]==a[i][j-1])
            {
                pos[i][j]=1;
                pos[i][j-1]=1;
                pr[i][j]=1;

            }
        }

    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
    {
        hertz[i][j]=pr[i][j]+pos[i][j];
    }

   // for(i=1;i<=n;i++)
 //   {for(j=1;j<=n;j++)
   // cout<<hertz[i][j]<<' ';
   // cout<<endl;
 //  }


 for(i=2;i<=n-2;i++)
    for(j=2;j<=n-2;j++)
 {
     if(hertz[i][j]>3)
     {
         bi=i;bj=j;
         lock=0;
        //cout<<"YES 1"<<endl;
       // cout<<bi<<' '<<bj<<endl;
        findwallright();
        }
 }

cout<<cw<<' '<<ci<<' '<<cj<<endl;
return 0;
}
/*
6
1 1 4 4 13 14
2 3 3 5 13 14
2 6 7 5 12 12
9 6 7 10 10 15
9 8 8 11 11 15
16 16 17 17 18 18
*/
