Time limit
5s
Memory limit
128 MB
You are given N words consisting only of uppercase English letters. Print the shortest string that contains every given word as a substring.
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.
Print the answer on the first line. If there are multiple possible answers, print the lexicographically smallest one.