Word Game
시간 제한2초메모리 제한2048 MB
한 단어의 접미사와 다른 단어의 접두사가 겹치도록 두 단어를 합쳐, 만들 수 있는 가장 짧고 사전순으로 앞선 단어를 구한다.
문제
On the Word Game show, Ashley has selected words and asks Brandon to combine them. Two words and can be combined if has a suffix of length that is a prefix of . The result of combining them is a new word made of concatenated with the last letters of . If there are multiple values of that are valid, any can be chosen.
Brandon must repeatedly take a pair of words from the list of words that can be combined, and replace them in the list with the combined word, until the list contains only a single word, and that word is as short as possible. If multiple final words of the same length are possible, Brandon must find the lexicographically first one.
입력
The first line of the input contains a single integer , the number of words to start out with.
The next lines each contain a single word in lowercase letters of length at most 5.
출력
Output the lexicographically first word of minimum length Brandon can come up with. If it is not possible to come up with a single word, output .