#include #define REP(A,B) for(int (A)=0;(A)<(B);(A)++) #define ll long long char str[27][30]; int cnt[27]; int cC[27][27], cR[27][27]; int main() { int n; while(scanf("%d", &n)==1) { REP(i, 27) cnt[i] = 0; REP(i, n) scanf("%s", str[i]); REP(i, n) REP(j, n) { cnt[str[i][j]-'A']++; cR[i][str[i][j]-'A']++; cC[j][str[i][j]-'A']++;} bool found = false; REP(i, 26) if(cnt[i]==1) { char x; REP(j, 26) if(cnt[j] == n-1) { x = j+'A'; } REP(j, n) REP(k, n) if(str[j][k]==i+'A') { printf("%d %d %c\n", j+1, k+1, x); found = true; j = k = i = 80; break; } } if(!found) { REP(i, 26) if(cnt[i]==n+1) { char x; REP(j, 26) if(cnt[j] == n-1) { x = j+'A'; } REP(j, n) REP(k, n) if(str[j][k]==i+'A'&&cR[j][i]==2&&cC[k][i]==2) { printf("%d %d %c\n", j+1, k+1, x); found = true; j = k = i = 80; break; } } } } return 0; }