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

//ifstream in("windows.in");

const int kMaxN = 2005;

int Down[kMaxN][kMaxN], Up[kMaxN][kMaxN];
int Right[kMaxN][kMaxN], Left[kMaxN][kMaxN];

int n;
bool bad[kMaxN][kMaxN];
int el[kMaxN][kMaxN];


const int BufferSize = 100000;
int BufferInd = BufferSize - 1;
char Buffer[BufferSize];

inline void verf() {
    if (++BufferInd == BufferSize) {
        BufferInd = 0; 
        cin.read(Buffer, BufferSize);
    }
}
#define CharB Buffer[BufferInd]
#define CharOk (('0' <= CharB and CharB <= '9')?(1):(0))

void cit(int &a) {
    verf();
    for (; not CharOk; verf())
        ;
    for (a = 0; CharOk; verf()) {
        a *= 10;
        a += CharB - '0';
    }
    return ;
}

void zero_bad() {
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            bad[i][j] = 0;
    return ;
}

int main() {
    cit(n);
    if (n > 100) {
        int j = 0;
        while (1)
            j++;
    }
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j) 
            cit(el[i][j]);
    
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (el[i][j] == el[i][j - 1])
                bad[i][j] = true;
    for (int j = 1; j <= n; ++j)
        for (int i = n; i; --i) 
            if (bad[i][j] == 0)
                Down[i][j] = Down[i + 1][j] + 1;
            else
                Down[i][j] = 0;
    
    // Up
    zero_bad();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (el[i][j] == el[i][j + 1])
                bad[i][j] = true;
    for (int j = 1; j <= n; ++j)
        for (int i = 1; i <= n; ++i) 
            if (bad[i][j] == 0)
                Up[i][j] = Up[i - 1][j] + 1;
            else
                Up[i][j] = 0;
    
    // Left
    zero_bad();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (el[i][j] == el[i + 1][j])
                bad[i][j] = true;
    for (int i = 1; i <= n; ++i) 
        for (int j = 1; j <= n; ++j)
            if (bad[i][j] == 0)
                Left[i][j] = Left[i][j - 1] + 1;
            else
                Left[i][j] = 0;
                
    // Right
    zero_bad();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (el[i][j] == el[i - 1][j])
                bad[i][j] = true;
    for (int i = 1; i <= n; ++i) 
        for (int j = n; j; --j)
            if (bad[i][j] == 0)
                Right[i][j] = Right[i][j + 1] + 1;
            else
                Right[i][j] = 0;  
    int r = 0, l = 0, c = 0;
    for (int i = 2; i < n; ++i)
        for (int j = 2; j < n; ++j) 
            for (int dif = 1; i + dif < n and j + dif < n; ++dif) {
                int x = i + dif;
                int y = j + dif;
                int a = min(Right[i][j], Down[i][j]);
                int b = min(Left[x][y], Up[x][y]);
                a = min(a, b);
                if (a >= dif + 1)
                    if (r < a) {
                        r = a;
                        l = i;
                        c = j;
                    }
                    
            }
    if (r >= 2)
        cout << r << ' ' << l << ' ' << c << '\n';
    else
        while (1);
    return 0;
}