#include #include #include #include using namespace std; int main() { while (cin.good() && !cin.eof()) { uint32_t lines; cin >> lines; if (cin.eof()) return 0; std::vector fans; fans.resize(lines*lines); for (uint32_t i = 0; i < lines*lines; ++i) { char c; cin >> c; fans[i] = c; } std::unordered_set row; for (uint32_t y = 0; y < lines; ++y) { row.insert(fans[y*lines]); } for (uint32_t x = 1; x < lines; ++x) { for (uint32_t y = 0; y < lines; ++y) { if (row.find(fans[y*lines+x]) == row.end()) { //std::cout << "Expectation failed for " << fans[y*lines+x] << "!" << endl; for (uint32_t y = 0; y < lines; ++y) { row.erase(fans[y*lines+x]); } //cout << row.size() << ' ' << *row.begin() << endl; uint32_t gotX = x; uint32_t gotY = y; char expected = *row.begin(); char got = fans[y*lines+x]; //cout << "Expected " << expected << " got " << got << endl; if (x == 1) { //cout << "First" << endl; row.clear(); for (uint32_t yThird = 0; yThird < lines; ++yThird) { row.insert(fans[yThird*lines+2]); } if (row.find(expected) == row.end()) { //cout << "Didn't find expected in line 2" << endl; for (uint32_t yFirst = 0; yFirst < lines; ++yFirst) { //cout << yFirst << " got :" << fans[yFirst*lines] << endl; if (fans[yFirst*lines] == expected) { //cout << "got y " << endl; gotY = yFirst; } } expected = got; gotX = 0; } } cout << gotY+1 << ' ' << gotX+1 << ' ' << expected << endl; goto label; } } } label:; } return 0; }