#include #include #include using namespace std; int main() { int n; while (cin >> n) { int right, right2, t; string s[26]; for (int i = 0; i < n; ++i) { cin >> s[i]; } int size = s[0].length(); string sorted[26]; for (int i = 0; i < n; ++i) { sorted[i] = s[i]; } for (int i = 0; i < n; ++i) { sort(sorted[i].begin(), sorted[i].end()); } if (sorted[0] != sorted[1]) { if (sorted[0] != sorted[2]) right = 0; else right = 1; } else for (int i = 1; i < n; ++i) { if (sorted[0] != sorted[i]) { right = i; break; } } if (right == 0) t = 1; else t = 0; char missing; for (int i = 0; i < size; ++i) { std::string::size_type pos = s[t].find(s[right][i]); if (pos == std::string::npos) { right2 = i; break; } else if (std::count(s[right].begin(), s[right].end(), s[right][i]) == 2) { for (int j = 0; j < n; ++j) { for (int k = 0; k < n; ++k) { if (k == right) continue; if (s[k][j] == s[right][i] && j == i) { cout << right+1 << " " << j+1 << " "; for (int p = 0; p < s[right].length(); ++p) { if (s[right].find(s[t][p]) == string::npos) { cout << s[t][p] << endl; goto g; } } } } } } } for (int i = 0; i < size; ++i) { if (s[right].find(s[t][i]) == std::string::npos) { missing = s[t][i]; break; } } cout << right + 1 << " " << right2 + 1 << " " << missing << endl; g: ; } }