#include using namespace std; using pii = pair; using ll = long long; #define NMAX 110 #define LMAX 1001 string words[NMAX], sol; set m; bool dp[LMAX]; bool exists(int p, int i, int j) { return m.find(words[p].substr(i, j - i + 1)) != m.end(); } bool ok(int p, int n) { memset(dp, 0, sizeof dp); for(int i = 0; i < words[p].size(); ++i) { for(int j = 0; j <= i && !dp[i]; ++j) if(i - j + 1 < words[p].size() && exists(p, j, i) && (j == 0 || dp[j - 1])) dp[i] = true; } return dp[words[p].size() - 1]; } int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); freopen("data.out", "w", stdout); #endif int i, n; cin >> n; for(i = 1; i <= n; ++i) cin >> words[i], m.insert(words[i]); for(i = 1; i <= n; ++i) { if(ok(i, n) && sol.size() < words[i].size()) sol = words[i]; } if(sol.empty()) cout << -1 << '\n'; else cout << sol << '\n'; return 0; }