cho.sh
Notes
Loading...

Merge Words

Time limit

5s

Memory limit

128 MB

Problem

You are given N words consisting only of uppercase English letters. Print the shortest string that contains every given word as a substring.

Input

The first line contains the number of words N (1 <= N <= 12). Each of the next N lines contains one word consisting only of uppercase English letters. Each word has length at most 50.

Output

Print the answer on the first line. If there are multiple possible answers, print the lexicographically smallest one.