e-olymp
Competitions

Sequences + Longest Common Subsequence

Longest Common Substring

n strings are given. Find their common substring of maximum length. It is known that its length is positive.

Input

First line contains the number of strings n (1n105). Each of the next n strings contains one line of lowercase Latin letters. The total sum of strings' length is no more than 105.

Output

Print the common substring of maximum length.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2
abaabbbba
aabaaba
Output example #1
abaab