#include <cctype>

#include <algorithm>
#include <fstream>
#include <iostream>
using namespace std;
const int MAX_N = 2004;
const int MAX_BUFFER_SIZE = 1 << 16;

int a[MAX_N][MAX_N];
int c[MAX_N][MAX_N];
int d[MAX_N][MAX_N];
int e[MAX_N][MAX_N];
int f[MAX_N][MAX_N];

class InputReader {
    private:
        char buffer[MAX_BUFFER_SIZE];
        int cursor;
        inline void advance() {
            ++ cursor;
            if (cursor == MAX_BUFFER_SIZE) {
                cursor = 0;
                fread(buffer, MAX_BUFFER_SIZE, 1, stdin);
            }
        }
    public:
        InputReader() {
            cursor = 0;
            fread(buffer, MAX_BUFFER_SIZE, 1, stdin);
        }
        inline InputReader & operator >> (int &value) {
            value = 0;
            while (!isdigit(buffer[cursor])) {
                advance();
            }
            while (isdigit(buffer[cursor])) {
                value = value * 10 + buffer[cursor] - '0';
                advance();
            }
            return *this;
        }
};

int main () {
    ///freopen("f.in", "r", stdin);
    InputReader cin;
    int n;

    cin >> n;
    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            cin >> a[i][j];
        }
    }

    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {

            if (a[i][j] == a[i][j + 1]) {
                c[i][j] = 0;
            } else {
                c[i][j] = c[i - 1][j] + 1;
            }

            if (a[i][j] == a[i][j - 1]) {
                d[i][j] = 0;
            } else {
                d[i][j] = d[i - 1][j] + 1;
            }

            if (a[i][j] == a[i + 1][j]) {
                e[i][j] = 0;
            } else {
                e[i][j] = e[i][j - 1] + 1;
            }

            if (a[i][j] == a[i - 1][j]) {
                f[i][j] = 0;
            } else {
                f[i][j] = f[i][j - 1] + 1;
            }

        }
    }

    for (int length = n - 2; length >= 2; length -= 2) {
        for (int i = 2; i <= n - length; ++ i) {
            for (int j = 2; j <= n - length; ++ j) {
                if (f[i][j + length - 1] >= length &&
                    e[i + length - 1][j + length - 1] >= length &&
                    d[i + length - 1][j] >= length &&
                    c[i + length - 1][j + length - 1] >= length) {
                        cout << length << " " << i << " " << j << "\n";
                        return 0;
                }
            }
        }
    }

    return 0;
}
