#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) int main() { int N; cin >> N; vector> S(N, vector (26, 0)); rep(i, N) { string Si; cin >> Si; for (char c : Si) S[i][c - 'a']++; } rep(i, N) { int ap = -1; string T; rep(j, N) { if (i == j) continue; int dif = 0; T = ""; int is = 0, js = 0; rep(k, 26) { rep(l, S[i][k]) T += char(int('a') + k); is += S[i][k]; js += S[j][k]; dif += abs(S[i][k] - S[j][k]); if (ap < 0 && S[i][k] == 0 && S[j][k] == 0) ap = k; } if (is == js && dif <= 1) { ap = -1; break; } } if (ap < 0) continue; cout << T << char(int('a') + ap) << endl; return 0; } cout << -1 << endl; return 0; }