#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<fstream>
#include<stack>
//#include<pair>

using namespace std;

#define MAXN 2048



long long n,ans1,ans2,ans3;
long long ma3x[MAXN][MAXN];
bool bma3x[MAXN][MAXN];
//bool sr[MAXN];
stack<pair<int, int> > s;


void input()
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    //ifstream in("asd");
    cin>>n;
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) cin>>ma3x[i][j];
    //in.close();
}


bool check_for(int x, int y, int c)
{
    int i;
    for(i=0;i<=c;i++,i++) if(bma3x[x+i][y+c]==0||bma3x[x+c][y+i]==0) return false;
    //cout<<" noice"<<endl;
    return true;

}



void solve()
{
    int i,j;
    for(i=1;i<n-2;i++)
    for(j=1;j<n-2;j++)
    {
        if( (ma3x[i][j]==ma3x[i+1][j]&&ma3x[i][j+1]==ma3x[i+1][j+1])
         || (ma3x[i][j]==ma3x[i][j+1]&&ma3x[i+1][j]==ma3x[i+1][j+1]) ) {
             //cout<<" here is ok "<<i<< " "<<j<<endl;
             s.push(make_pair(i,j));
             bma3x[i][j]=1;
         }
    }

    ans1=2;
    ans2=s.top().first;
    ans3=s.top().second;

    while(!s.empty())
    {
        long long c=2;
        int x,y;
        x=s.top().first;
        y=s.top().second;
        s.pop();

        while(check_for(x,y,c)) c+=2;
        if(c>ans1){
            //cout<<"da"<<endl;
            ans1=c;
            ans2=x;
            ans3=y;
        }
    }
    cout<<ans1<<" "<<ans2+1<<" "<<ans3+1<<endl;
}

int main()
{
    input();
    solve();
    return 0;
    }


