编程介的小学生 2017-05-02 06:33 采纳率: 20.5%
浏览 893
已采纳

Domain Name

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

gali

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-16 15:57
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器