#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()); } void poz(int x, int y) { string c = s[x], S = s[y]; int i = 0, j = 0; while (i < S.size()) { j = 0;bool u = 0; while (S[i] == c[j] && j < c.size() && i < S.size()) i++, j++, u = 1; if (j == c.size()) a[x][y] += c.size(); if (u) continue; else i++; } } 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) != -1) rs = y, z = 0; } if (rs == s[i]) return cout << rs, 0; } } cout << -1; }