#include<iostream>
#include<fstream>
#include<cstdlib>
#include<iomanip>
#include<set>
#include<map>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<queue>
#include<stack>
#include<cmath>
#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int, int>
using namespace std;

int maxk = -1, maxi, maxj;
ll a[2000][2000];
ll sumX[2000][2000];
ll sumY[2000][2000];
int L = 2, R = 3, B = 4, T = 5;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};

int n;
bool inn(int x, int y) {
    if (x < 0) return false;
    if (y < 0) return false;
    if (x >= n) return false;
    if (y >= n) return false;
}
int getT(int x, int y) {
    
}
bool used[4000000];


bool good(int x, int y, int k) {
    return (sumX[x + k][y] - sumX[x - 1][y] == 0) &&
           (sumX[x + k][y + k] - sumY[x - 1][y + k] == 0) &&
           (sumY[x][y + k] - sumY[x][y - 1] == 0) &&
           (sumY[x + k + 1][y + k] - sumY[x + k + 1][y - 1] == 0);
}

int main(void) {
    scanf("%d", &n);
    int tm;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &tm);
            a[i][j] = tm;
        }
    }
    /*for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (used[a[i][j]]) {
                a[i][j] = -a[i][j];
            }
            else used[a[i][j]] = true;
        }
    }*/
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (j > 0) {
                sumY[i][j] = sumY[i][j - 1];
                sumX[j][i] = sumX[j - 1][i];
            }
            if (a[i - 1][j] == a[i][j]) {
                sumY[i][j]++;
            }
            if (a[j][i - 1] == a[i][j]) {
                sumX[j][i]++;
            }
        }
    }
    for (int k = n - 1; k >= 0; --k) {
        for (int i = 1; i < n - 1; ++i) {
            if (i + k >= n - 1) continue;
            for (int j = 1; j < n - 1; ++j) {
                if (j + k >= n - 1)
                    continue;
                if (good(i, j, k)) {
                    cout << k + 1 << " " << i + 1 << " " << j + 1 << endl;
                    return 0;
                }
            }
        }
    }
}
