#include #include struct Point { Point(int xx, int yy) { x = xx; y = yy; } int x, y; }; int main() { int n; while ( std::cin >> n ) { int c[30] = {}; int posx[30] = {}; int posy[30] ={}; for ( int i=0; i > line; int dresy[30] = {}; for ( unsigned int j=0;j 1 || c[ line[j] - 'A' ] == 1) { posx[line[j] - 'A'] = i; posy[line[j] - 'A'] = j; } } } for ( int i = 0; i<27; i++ ) { if (c[i] == 1 || c[i] == n+1 ) std::cout << posx[i]+1 << " " << posy[i]+1 << " "; /*if (c[i] > max ) { last_max_pos = max_pos; max_pos = i; max = c[i]; }*/ } for ( int i = 0; i<27; i++ ) { if (c[i] == n-1) std::cout << (char)(i + 'A') << std::endl; } } }