#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define D(a) cerr << ">>> " << #a << " >" << a << "<" << endl; #define R1(a) scanf("%d", &a); #define R2(a) scanf("%d%d", &a,&b); #define R3(a) scanf("%d%d%d", &a,&b,&c); #define DR1(a) int a;scanf("%d", &a); #define DR2(a) int a,b;scanf("%d%d", &a,&b); #define DR3(a) int a,b,c;scanf("%d%d%d", &a,&b,&c); #define INF 1.0e20 typedef long long int ll; typedef pair pii; typedef vector vi; char matrix[26][26]; char first[26], second[26], third[26]; int setC[26]; int compare(const void * a, const void * b) { return *((char *) a) - *((char *) b); } int main() { int N; while(scanf("%d ", &N) > 0) { FOR(i,0,N-1) { FOR(j,0,N-1) { matrix[i][j] = getchar(); } getchar(); } FOR(i,0,N-1) first[i] = matrix[0][i]; FOR(i,0,N-1) second[i] = matrix[1][i]; FOR(i,0,N-1) third[i] = matrix[2][i]; qsort(first, N, 1, compare); qsort(second, N, 1, compare); qsort(third, N, 1, compare); FOR(i,0,25) { setC[i] = -1; } if (memcmp(first, second, N) == 0) { FOR(i,0,N-1) { setC[first[i] - 'A'] = 1; } } else { FOR(i,0,N-1) { setC[third[i] - 'A'] = 1; } } int k = 0, l = 0; for(k = 0; k < N; k++) { for(l = 0; l < N; l++) { setC[matrix[k][l] - 'A'] += 1; } for(l = 0; l < N; l++) { if (setC[matrix[k][l] - 'A'] == 0 || setC[matrix[k][l] - 'A'] == k + 3) { break; } } if (l < N) { break; } } if (setC[matrix[k][l] - 'A'] == 0) { FOR(j,0,25) { if (setC[j] == k + 1) { printf("%d %d %c\n", k + 1, l + 1, j + 'A'); } } } else { FOR(j,0,N-1) { if (matrix[k][j] == matrix[k][l]) { FOR(i,0,N-1) { if (i != k && matrix[i][j] == matrix[k][l]) { FOR(m,0,25) { if (setC[m] == k + 1) { printf("%d %d %c\n", k + 1, j + 1, m + 'A'); } } } } } } } } return 0; }