#include <cstdio>
#include <cstring>

#include <algorithm>

using namespace std;

class Reader {
  public:
    Reader(FILE *_stream, const int _size = 1 << 16):
      stream(_stream),
      size(_size),
      pointer(0),
      buffer(new char[size]) {
        fread(buffer, 1, size, stream);
    }
    
    int NextInt() {
        while ((Current() < '0' || Current() > '9') && Current() != '-')
            NextPosition();
        int value = 0;
        bool negative = false;
        if (Current() == '-') {
            negative = true;
            NextPosition();
        }
        while ('0' <= Current() && Current() <= '9') {
            value = value * 10 + Current() - '0';
            NextPosition();
        }
        if (negative)
            value = -value;
        return value;
    }
    
    Reader &operator>>(int &value) {
        value = NextInt();
        return *this;
    }
    
  private:
    FILE *stream;
    int size, pointer;
    char *buffer;
    
    char Current() const {
        return buffer[pointer];
    }
    
    void NextPosition() {
        if (++pointer == size) {
            pointer = 0;
            fread(buffer, 1, size, stream);
        }
    }
};

const int MAX_N = 2005;
const int oo = 0x3f3f3f3f;

int N, Board[MAX_N][MAX_N], Up[MAX_N][MAX_N], Right[MAX_N][MAX_N], Down[MAX_N][MAX_N], Left[MAX_N][MAX_N];
int MaxLength, BestX, BestY;

void Preprocess() {
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            Up[i][j] = Up[i][j - 1];
            Down[i][j] = Down[i][j - 1];
            if (Board[i][j] == Board[i + 1][j])
                ++Down[i][j];
            if (Board[i][j] == Board[i - 1][j])
                ++Up[i][j];
        }
    }
    for (int j = 1; j <= N; ++j) {
        for (int i = 1; i <= N; ++i) {
            Left[i][j] = Left[i - 1][j];
            Right[i][j] = Right[i - 1][j];
            if (Board[i][j] == Board[i][j - 1])
                ++Left[i][j];
            if (Board[i][j] == Board[i][j + 1])
                ++Right[i][j];
        }
    }
}

void Solve() {
    Preprocess();
    for (int l = N - 2; l > 0; l -= 2) {
        for (int x = 2; x + l - 1 < N; ++x) {
            for (int y = 2; y + l - 1 < N; ++y) {
                if (Up[x][y + l - 1] - Up[x][y - 1] > 0)
                    continue;
                if (Left[x + l - 1][y] - Left[x - 1][y])
                    continue;
                if (Down[x + l - 1][y + l - 1] - Down[x + l - 1][y - 1] > 0)
                    continue;
                if (Right[x + l - 1][y + l - 1] - Right[x - 1][y + l - 1] > 0)
                    continue;
                MaxLength = l;
                BestX = x;
                BestY = y;
                return;
            }
        }
    }
}

void Read() {
    Reader cin = Reader(stdin);
    cin >> N;
    for (int i = 1; i <= N; ++i)
        for (int j = 1; j <= N; ++j)
            cin >> Board[i][j];
}

void Print() {
    printf("%d %d %d\n", MaxLength, BestX, BestY);
}

int main() {
    //freopen("window.in", "r", stdin);
    Read();
    Solve();
    Print();
    return 0;
}
