#include #define ll long long using namespace std; ll n; string s[110]; int a[110][110]; bool cmp(string a, string b) { return (a.size() < b.size()); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> s[i]; sort(s+1, s+n+1,cmp); for (int i = n; i; i--) { for (int j = 1; j < i; j++) { string rs = s[j], y; if (s[i].find(rs) == -1) continue; for (int z = 1; z < i; z++) { y = rs + s[z]; if (s[i].find(y) == 0) rs = y, z = 0; } if (rs == s[i]) return cout << rs, 0; } } cout << -1; }