#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;

const int N = 1010;

int n, x[N][N], a[2 * N][2 * N], dist[2 * N][2 * N], dist1[2 * N][2 * N], dist2[2 * N][2 * N];
int val[2 * N][2 * N];
int rx = 1, ry = 1, rez = 1;

int aint[8 * N];

/*void debug(int a[2 * N][2 * N]) {
    int i, j;
    for(i = 1; i <= n; ++i) {
    for(j = 1; j <= n; ++j)
        cout << a[i][j] << " ";
        cout << "\n"; 
    }
    cout << "\n";
}*/

void update(int nod, int pozx, int pozy, int poz, int val) {
    if(pozx == pozy) {
        aint[nod] = val;
        return;
    }
    int mid = (pozx + pozy) / 2;
    
    if(mid >= poz)
        update(2 * nod, pozx, mid, poz, val);
    else
        update(2 * nod + 1, mid + 1, pozy, poz, val);
    
    aint[nod] = min(aint[2 * nod], aint[2 * nod + 1]);
}

int query(int nod, int pozx, int pozy, int poz1, int poz2) {
    if(aint[nod] > poz1)
        return 0;
    
    if(pozx == pozy)
        return pozx;
    
    int el, mid = (pozx + pozy) / 2;
    
    if(mid < poz2) {
        el = query(2 * nod + 1, mid + 1, pozy, poz1, poz2);
        if(el)
            return el;
    }
    if(mid >= poz1) {
        el = query(2 * nod, pozx, mid, poz1, poz2);
        if(el)
            return el;
    }
    return 0;
}

void calc(int pozx, int pozy, int nrel) {
    int i, elc = 1, po[2 * N], x1[2 * N], x2[2 * N];
    
    for(i = 0; i <= 4 * n; ++i)
        aint[i] = 10 * N;
    
    for(i = 1; i < nrel; ++i) {
        
        x1[elc] = elc - dist[pozx][pozy] + 1; // distanta in sus
        update(1, 1, n, elc, x1[elc]);
        x2[elc] = val[pozx][pozy];
        
        ++pozx; ++pozy;
        ++elc;
    }
    x1[elc] = dist[pozx][pozy]; // distanta in sus
    update(1, 1, n, elc, x1[elc]);
    x2[elc] = val[pozx][pozy];
    
    for(i = 1; i < nrel; ++i) {
        --pozx; --pozy; --elc;
        
        int rc = query(1, 1, n, elc, elc + x2[elc] - 1) - elc + 1;
        
        if(rc > rez) {
            rez = rc;
            rx = pozx;
            ry = pozy;
        }
    }
}

void sol() {
    int i, j;
    
    for(i = 1; i <= n; ++i)
        for(j = 1; j <= n; ++j) {
            if(a[i][j] == 1) {
                dist1[i][j] = dist1[i - 1][j] + 1;
                dist2[i][j] = dist2[i][j - 1] + 1;
            }
            
            dist[i][j] = min(dist1[i][j], dist2[i][j]);
        }
    
    memset(dist1, 0, sizeof(dist1));
    memset(dist2, 0, sizeof(dist2));
    
    for(i = n; i; --i)
        for(j = n; j; --j) {
            if(a[i][j] == 1) {
                dist1[i][j] = dist1[i + 1][j] + 1;
                dist2[i][j] = dist2[i][j + 1] + 1;
            }
            
            val[i][j] = min(dist1[i][j], dist2[i][j]);
        }
    
    //debug(dist3);
    //debug(dist4);
    //debug(val);
    
    for(i = 1; i < n; ++i) {
        calc(1, i, n - i + 1);
        calc(i, 1, n - i + 1);
    }
}

int main() {
    int i, j;
    //freopen("rrr", "r", stdin);
    
    cin >> n;
    
    for(i = 1; i <= n; ++i)
    for(j = 1; j <= n; ++j) {
        cin >> x[i][j];
    }
    
    for(i = 0; i < 2 * N; ++i)
        for(j = 0; j < 2 * N; ++j)
            a[i][j] = 1;
    
    for(i = 2; i < n; ++i)
        for(j = 2; j < n; ++j) {
            int cx = 2 * i - 2, cy = 2 * j - 2;
            a[cx][cy] = 0;
            
            if(x[i][j] == x[i - 1][j])
                a[cx - 1][cy] = 0;
            if(x[i][j] == x[i + 1][j])
                a[cx + 1][cy] = 0;
            if(x[i][j] == x[i][j - 1])
                a[cx][cy - 1] = 0;
            if(x[i][j] == x[i][j + 1])
                a[cx][cy + 1] = 0;
        }
    
    n = 2 * n - 3;
    
    //debug(a);
    
    sol();
    cout << rez / 2 << " " << rx / 2 + 2 << " " << ry / 2 + 2 << "\n";
    
    return 0;
}
