#Q63. 「一本通 2.4 练习 4」最短母串

    ID: 2145 Type: Default 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>DP状态压缩AC 自动机HNOI早于 2010一本通提高

「一本通 2.4 练习 4」最短母串

Description

Original source: HNOI 2006

Given nn strings S1,S2,,SnS_1,S_2,\cdots ,S_n, find the shortest string TT such that all nn strings are substrings of TT.

Input Format

The first line contains a positive integer nn, indicating the number of given strings;

The following nn lines each contain a string composed entirely of uppercase letters.

Output Format

Output only one line, the shortest string TT found.

If there are multiple strings that satisfy the requirement while being the shortest, the one that comes first in lexicographical order must be output.

Sample 1

2
ABCD
BCDABC

ABCDABC

Data Range and Hint

For all data, 1n12,1Si501\le n\le 12,1\le |S_i|\le 50.