2413. Abbreviation

单点时限: 3.0 sec

内存限制: 256 MB

World Abbreviation Organization (WAO for short) has announced the guideline to make various abbreviations comprehensible all over the world. In the guideline, abbreviation should be one word and the number of characters in an abbreviation should be less than the total number of characters in a base phrase. When a base phrase consists of two or more words, we should take one character from each word and sequentially connect them. If a word contains capital letters, we should take first appeared one. If a word does not contain a capital letter, we should take first appeared digit. In the other case, we should take the first character. If a base word consists of one word, its abbreviation should be a prefix of the base word, and the number of characters in an abbreviation should be at most three, and we should take as much characters as possible.

Your job is to write a program to generate abbreviations of given words or phrase based on the guideline.

输入格式

Input consists of multiple test cases. The first line of each test case contains a single positive integer n ( n <= 1,024), it indicates the number of words in a given word or phrase. The next line contains n words separated by a single space character. Input is terminated by a case of n = 0, and it should not be processed.

You can assume that there is at least one word which contains at least 2 characters in each test case. You can also assume that any word consists of alphabets or digits.

输出格式

For each test case, you should output an abbreviation to each line.

样例

Input
3
World Abbreviation Organization
4
International Collegiate Programming Contest
3
World Wide Web
3
TsubuTsubu Gaspacho Merlion
0
Output
WAO
ICPC
WWW
TGM

1 人解决,17 人已尝试。

1 份提交通过,共有 68 份提交。

9.9 EMB 奖励。

创建: 15 年,5 月前.

修改: 6 年,7 月前.

最后提交: 3 年,4 月前.

来源: Winter Contest 2008

题目标签