#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) #define rep2(i, j, n) for (int i = (int)j; i < (int)n; i++) using pii = pair; bool comp(pii a, pii b) { if (a.first != b.first) return a.first > b.first; else return a.second < b.second; } int main() { int N; cin >> N; vector> S(N, vector (26, 0)); vector sv(N); rep(i, N) { string Si; cin >> Si; for (char c : Si) S[i][c - 'a']++; sv.push_back({(int)Si.size(), i}); } sort(sv.begin(), sv.end(), comp); if (sv[0].first != sv[1].first) { int a = 0; rep(i, 26) { if (S[sv[0].second][i] == 0) a = i; rep(j, S[sv[0].second][i]) cout << char(int('a')+i); } cout << char(int('a')+a) << endl; } else { int a = 0; int dif = 0; rep(i, 26) { if (S[sv[0].second][i] != S[sv[1].second][i]) dif++; if (S[sv[1].second][i] == 0) a = i; } if (dif == 0) cout << -1 << endl; else { rep(i, 26) { rep(j, S[sv[0].second][i]) cout << char(int('a')+i); } cout << char(int('a')+a) << endl; } } return 0; }