// #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 c = 0; c < 26; ++ c){ ++ cnt[i][c]; for(auto j = 0; j < n; ++ j){ if(i != j){ for(auto d = 0; d < 26; ++ d){ ++ cnt[j][d]; if(cnt[i] == cnt[j]){ -- cnt[j][d]; goto FAIL; } -- cnt[j][d]; } } } for(auto c = 0; c < 26; ++ c){ cout << string(cnt[i][c], 'a' + c); } cout << "\n"; return 0; FAIL:; -- cnt[i][c]; } } cout << "-1\n"; return 0; } /* */