#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    scanf("%d", &n);
    
    int a[n][n];
    int s1[n][n];
    int s2[n][n];
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);
            s1[i][j] = s2[i][j] = 0;
        
            if (j > 0 && i > 0) {
                s1[i][j] = s1[i][j - 1];
                if (a[i][j] == a[i - 1][j]) {
                    ++s1[i][j];                        
                }
                
                s2[i][j] = s2[i - 1][j];
                if (a[i][j] == a[i][j - 1]) {
                    ++s2[i][j];
                }
            }
        }
    }
    
    int maxans = 0, ansi = 2, ansj = 2;
    for (int i = 1; i < n - 2; i++) {
        for (int j = 1; j < n - 2; j++) {
            bool ok = true;
            
            int l = i, r = n - 1;
            while (l + 1 < r) {
                int m = (l + r) / 2;
                if (s2[m][j] - s2[i - 1][j] > 0) {
                    r = m;
                } else {
                    l = m;                
                }
            }
            
            int i1 = l;
            
            l = j, r = n - 1;
            while (l + 1 < r) {
                int m = (l + r) / 2;
                if (s1[i][m] - s1[i][j - 1] > 0) {
                    r = m;
                } else {
                    l = m;
                }
            }
            
            int j1 = l;
            
            int mn = min(i1 - i, j1 - j) + 1;
            i1 = i + mn;
            j1 = j + mn;
            
            if (s1[i][j1 - 1] - s1[i][j - 1] != 0) ok = false;
            if (s1[i1][j1 - 1] - s1[i1][j - 1] != 0) ok = false;
            if (s2[i1 - 1][j] - s2[i - 1][j] != 0) ok = false;
            if (s2[i1 - 1][j1] - s2[i - 1][j1] != 0) ok = false;

            if (ok) {
                if (mn > maxans) {
                    maxans = mn;
                    ansi = i + 1;
                    ansj = j + 1;
                }
            }
        }
    }
    
    cout << maxans << ' ' << ansi << ' ' << ansj << endl;
}
