// #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){ int req = 0; for(auto d = 0; d < 26; ++ d){ if(cnt[i][d] == cnt[j][d]){ continue; } if(cnt[i][d] == cnt[j][d] + 1){ ++ req; } else{ goto OK; } } if(req != 1){ goto OK; } goto FAIL; OK:; } } 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; } /* */