Domain Name
Time Limit: 1 Second Memory Limit: 32768 KB
ID, short for identity, is the name of the people on BBS. Domain name, is short for name of a country on the internet. One day, some students on ZJU freecity BBS found that, there is great relation between a ID and a domain name. We say that a ID contains a domain name, if and only if(1) the two letters of the domain name can both be found in the ID;
(2) the order of the letter in the domain name and ID are the same.
Take example of the ID gali:
ga : domain name for Gobon
gl : domain name for Greenland
gi : domain name for Gibraltar
al : domain name for Albania
ai : domain name for Anguilla
li : domain name for Liechtenstein
We can say gali contains 6 domain names, ga, gl, gi, al, ai and li.
We consider ID 1 is better than ID 2 if
(1) ID 1 contains more domain name than ID 2 or
(2) ID 1 contains the same domain name as ID 2, and ID 1 is shorter than ID
2 or
(3) ID 1 contains the same domain name as ID 2, and they are of the same length,
and ID 1 precedes ID 2 in alphabetical order.
Give n domain names, you are to judge whether there are some IDs, with length no more than twelve, contain all the n domain names.
Input
A line contain n.
Next n lines contain a domain name each. A domain name always contains two lowercase
letters, with no space embedded.
Process to the end of file.
Output
If such ID does not exist, output an "impossible", otherwise output the best ID.
Sample Input
6 ga gl gi al ai li
Sample Output
galiSubmit
Source: Zhejiang University 2003 Summer Camp Qualification Contest