#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } bool check(vector a, vector b) { assert(a.size() == b.size() && a.size() == 26); int cnt = 0; for (int i = 0; i < 26; i++) { if (a[i] < b[i] || a[i] > b[i] + 1) { return false; } if (a[i] != b[i]) { cnt++; } } return cnt == 1; } int main() { fast_io(); int n; cin >> n; vector s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } 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++) { for (int c = 0; c < 26; c++) { cnt[i][c]++; bool is_ok = true; for (int j = 0; j < n; j++) { if (i == j) { continue; } if (check(cnt[i], cnt[j])) { is_ok = false; break; } } if (is_ok) { for (int k = 0; k < 26; k++) { for (int l = 0; l < cnt[i][k]; l++) { cout << (char)('a' + k); } } cout << endl; return 0; } cnt[i][c]--; } } cout << "-1" << endl; }