#2629 아몰랑

1 s   128 MB  

Description

A word is grouped if, for each letter in the word, all occurrences of that letter form exactly one consecutive sequence. In other words, no two equal letters are separated by one or more letters that are different. For example, the words "ccazzzzbb" and "code" are grouped, while "aabbbccb" and "topcoder" are not.
 
 
 
A grouped word was divided into several parts. You are given all the parts in random order as a String[]. Reconstruct the original word and return it. If there is more than one possible answer, return "MANY" instead. If no grouped word could have resulted in the given parts, return "IMPOSSIBLE" instead (all quotes for clarity).

Input

입력의 첫번째 줄에 testcase의 수가 주어진다. 각 testcase는 조각의 개수 n과 단어 조각으로 구성 되어있다.
각 testcase의 첫번째 줄에는 조각의 개수 n이 주어진다. 다음 n행에 걸쳐 단어 조각이 주어진다.각 단어는 알파벳 소문자로 이루어져 있고 20자를 넘지 않는다.
 
1 <= n <= 50

Sample Input

Sample Output

1
3
dou
ghn
uts
MANY