# JAG-channel II

Time Limit : 3 sec, Memory Limit : 262144 KB

## Problem G JAG-channel II

JAG (Japan Alumni Group) is a group of $N$ members that devotes themselves to activation of the competitive programming world. The JAG staff members talk every day on the BBS called JAG-channel. There are several threads in JAG-channel and these are kept sorted by the time of their latest posts in descending order.

One night, each of the $N$ members, identified by the first $N$ uppercase letters respectively, created a thread in JAG-channel. The next morning, each of the $N$ members posted in exactly $K$ different threads which had been created last night. Since they think speed is important, they viewed the threads from top to bottom and posted in the thread immediately whenever they came across an interesting thread. Each member viewed the threads in a different period of time, that is, there was no post of other members while he/she was submitting his/her $K$ posts.

Your task is to estimate the order of the members with respect to the periods of time when members posted in the threads. Though you do not know the order of the threads created, you know the order of the posts of each member. Since the threads are always kept sorted, there may be invalid orders of the members such that some members cannot post in the top-to-bottom order of the threads due to the previous posts of other members. Find out the lexicographically smallest valid order of the members.

### Input

The input consists of a single test case. The first line contains two integers separated by a space: $N$ $(4 \leq N \leq 16)$ and $K$ $(N - 3 \leq K \leq N - 1)$. Then $N$ lines of strings follow. Each of the $N$ lines consists of exactly $K$ distinct characters. The $j$-th character of the $i$-th line denotes the $j$-th thread in which the member denoted by the $i$-th uppercase letter posted. Each thread is represented by its creator (e.g. 'B' represents the thread created by member B, the second member).

It is guaranteed that at least one valid order exists.

### Output

Display a string that consists of exactly $N$ characters in a line, which denotes the valid order in which the members posted in the threads. The $i$-th character of the output should represent the member who posted in the $i$-th period. In case there are multiple valid orders, output the lexicographically smallest one.

### Sample Input 1

7 4
DEFG
FEDA
EFGB
BGEA
AGFD
DABC
CADE

### Output for the Sample Input 1

ABCDEFG

### Sample Input 2

4 3
CDB
DAC
ABC

### Output for the Sample Input 2

DCBA

### Sample Input 3

16 13
NDHPFJIBLMCGK
CMDJKPOLGIHNE
KPNAOHBLMCGEI
FCMLBHDOANJPK
NHIGLOAPKJDMC
KMLBIPHDEOANJ
IEGCMLBOAPKJD
JNAOEDHBLMCGF
OEDHPFIBLMGKC
GMLBIFPHDNAEO
ENHGOPKJDMCAF
JKPAOBLGEIHNF
HPKFGJEIBLCOM
LBINEJDAGFKPH
FGMOCADJENIBL

### Output for the Sample Input 3

PONCAKJGIEDHMFBL

Source: Japan Alumni Group Spring Contest 2015 , Japan, 2015-04-19
http://acm-icpc.aitea.net/
http://jag2015spring.contest.atcoder.jp/