#include using namespace std; int main() { int n; cin >> n; vector s(n); for (int i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); s.erase(unique(s.begin(), s.end()), s.end()); if (s.size() == 1) { cout << -1 << endl; return 0; } vector> cnt(n, vector(26)); for (int i = 0; i < n; i++) { for (char c : s[i]) { cnt[i][c - 'a']++; } } for (int i = 0; i < n; i++) { vector v = cnt[i]; for (char c = 'a'; c <= 'z'; c++) { v[c - 'a']++; bool ok = true; for (int ni = 0; ni < n; ni++) { if (i == ni) { continue; } int zero = 0, one = 0; for (int j = 0; j < 26; j++) { if (v[j] == cnt[ni][j]) { zero++; } if (v[j] - cnt[ni][j] == 1) { one++; } } if (zero == 25 && one == 1) { ok = false; } } if (ok) { cout << s[i] + c << endl; return 0; } } } }