Palindrome
Hard
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
You are given n words. Find the shortest palindrome (a word that is the same with its reverse) containing all of them as contiguous substrings.
Input
The first line contains an integer n (1 ≤ n ≤ 14). The next n lines contain one word each, between 1 and 30 characters long. All the characters are small English letters a through z.
Output
Output the required palindrome. If there're several possible solutions, output any.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 56
Acceptance rate 9%