/* * File: main.cpp * Author: cteam027 * * Created on October 22, 2016, 12:20 PM */ #include #include using namespace std; /* * */ int Check( int a, int b, int c ) { if( a == b && a == c ) return -1; if( a == b ) return 2; if( a == c ) return 1; if( c == b ) return 0; return 0; } int main(int argc, char** argv) { int n; string s; while( true ) { if( !(cin >> n) ) break; int pole[n+1][n+1]; for( int i = 0; i < n+1; i++ ) { pole[n][i] = 0; pole[i][n] = 0; } for( int i = 0; i < n; i++ ) { cin >> s; for( int j = 0; j < (int)(s . length()); j++ ) { pole[i][j] = (int)s[(int)j]; pole[n][i] += (int)s[(int)j]; pole[j][n] += (int)s[(int)j]; } } int x = 0, y = 0; for( int i = 0; i < n; i+=1 ) { if(i > n-2) break; int tmp; if( ( tmp = Check( pole[n][i], pole[n][i+1], pole[n][i+2] )) != -1){ x = tmp + i; break; } } for( int i = 0; i < n; i+=1 ) { if(i > n-2) break; int tmp; if( ( tmp = Check( pole[i][n], pole[i+1][n], pole[i+2][n] )) != -1){ y = tmp + i; break; } } int tmp = 0; char c = '0'; bool ok = false; if( x == 0 ) tmp = 1; else if( x > 0 ) tmp = x -1; //cout << x << " " << tmp << endl; for( int i = 0; i < n; i++ ) { for( int j = 0; j < n; j++ ) { //cout << (char)pole[tmp][i] << " " << (char)pole[x][j] << endl; if( pole[tmp][i] == pole[x][j] ) { ok = true; break; } } if( !ok ) { c = (char)pole[tmp][i]; break; } ok = false; } cout << x + 1 << " " << y + 1 << " " << c << endl; /* int res = 0; int wrong = pole[x][n]; int right = 0; if(x == 0){ right = pole[1][n]; }else{ right = pole[x-1][n]; } if(wrong > right){ res = pole[x][y] + (wrong - right); } else{ res = pole[x][y] - (right - wrong); } //cout << (char)res << endl; cout << x + 1 << " " << y + 1 << " " << (char)res << endl; */ } return 0; }