#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cassert>

typedef long long ll;
typedef long double ld;

using namespace std;

int n;

int wall[2001][2001];

vector<vector<int> > vert, horz;

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "r", stdout);
#endif
    cin >> n;
    horz.resize(n + 1);
    vert.resize(n + 1);
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            scanf("%d", &wall[i][j]);
            if(wall[i][j] == wall[i-1][j]) {
                horz[i].push_back(j);
            }
            if(wall[i][j] == wall[i][j-1]) {
                vert[j].push_back(i);
            }
        }
    }
    /**for(int i = 1; i <= n; i++){
        cerr << i << " :";
        for(int j = 0; j < horz[i].size(); j++){
            cerr << " " << horz[i][j];
        }
        cerr << "\n";
    }
    for(int i = 1; i <= n; i++){
        cerr << i << " :";
        for(int j = 0; j < vert[i].size(); j++){
            cerr << " " << vert[i][j];
        }
        cerr << "\n";
    }*/
    for(int l = n - 2; l > 0; l -= 2) {
        for(int a = 2; a + l <= n; a++) {
            for(int b = 2; b + l <= n; b++) {
                //cerr << l << " " << a << " " << b << "\n";
                bool res = true;
                res = res && (lower_bound(vert[b  ].begin(), vert[b  ].end(), a) == lower_bound(vert[b  ].begin(), vert[b  ].end(), a + l));
                res = res && (lower_bound(vert[b+l].begin(), vert[b+l].end(), a) == lower_bound(vert[b+l].begin(), vert[b+l].end(), a + l));
                res = res && (lower_bound(horz[a  ].begin(), horz[a  ].end(), b) == lower_bound(horz[a  ].begin(), horz[a  ].end(), b + l));
                res = res && (lower_bound(horz[a+l].begin(), horz[a+l].end(), b) == lower_bound(horz[a+l].begin(), horz[a+l].end(), b + l));
                if(res) {
                    cout << l << " " << a << " " << b << "\n";
                    return 0;
                }
            }
        }
    }
    return 0;
}
