#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> 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<vector<int>> cnt(n, vector<int>(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<int> v = cnt[i];
        for (int j = 0; j < (int)s[i].size(); j++) {
            v[s[i][j] - 'a']++;
            bool ok = true;
            for (int ni = 0; ni < n; ni++) {
                if (i == ni) {
                    continue;
                }
                if (v == cnt[ni]) {
                    ok = false;
                }
            }
            if (ok) {
                cout << s[i] + s[i][j] << endl;
                return 0;
            }
        }
    }
}