// #pragma GCC optimize("O3,unroll-loops") #include // #include using namespace std; #if __cplusplus >= 202002L using namespace numbers; #endif int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n; cin >> n; vector> cnt(n); for(auto i = 0; i < n; ++ i){ string s; cin >> s; for(auto c: s){ ++ cnt[i][c - 'a']; } } for(auto i = 0; i < n; ++ i){ for(auto j = 0; j < n; ++ j){ if(i == j){ continue; } bool ok = false; for(auto c = 0; c < 26; ++ c){ if(cnt[i][c] > cnt[j][c]){ ok = true; break; } } if(!ok){ goto FAIL; } } for(auto c = 0; c < 26; ++ c){ cout << string(cnt[i][c], 'a' + c); } cout << "\n"; return 0; FAIL:; } cout << "-1\n"; return 0; } /* */