Innokenty and a Football League

题意翻译

## 描述 给出 $n$ 对字符串(分别是A串,B串),要求你对每一对字符串构造一个长度为3的短字符串。 短字符串有如下两种构造方式 1. A串的前3个字符 2. A串的前2个字符和B串的第一个字符 举例说明: **XYZ**CCF **C**CA 合法的构造分别为 XYZ(A串的前3个, **XYZ** ) XYC(A串的前2个 **XY** 和B串的第一个**C**) 以下构造是不合法的 XYZC (多出了一个字符) ZYX (打乱的原来的顺序) **特别限制: 如果一对字符串 $x$ 选择了第2个构造方式,那么对于其他任意字符串对 $y$ ,如果满足$y$ 选择第一个构造方式和 $x$选择第一个构造方式的构造结果相同,那么 $y$也必须选择第二个构造方式。(请仔细阅读这句话) ** 举例说明 XXY ZZF XXY CCF XXC DCF 第一个字符串选择 `XXZ` 的时候 第二个字符串必须选择 `XXC` 而第三个字符串没有必要选择 `XXD` , 因为其第一构 造的结果为 `XXC` 而不是`XXY` 对于输入的 $n$ 对字符串,请对每一对构造一个"短字符串" 使得构造结果都不同。 ## 输入 第一行一个整数 $n$ 代表字符串的数量 接下来 $n$ 行,每行两个字符串,表示第 $i$ 个字符串对 ## 输出 如果存在合法构造,输出`YES` 然后输出n行,你的短字符串构造结果 如果不存在合法构造,输出`NO` 如果存在多个解,输出任何一组即可

题目描述

Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all short names consist of three letters. Each club's full name consist of two words: the team's name and the hometown's name, for example, "DINAMO BYTECITY". Innokenty doesn't want to assign strange short names, so he wants to choose such short names for each club that: 1. the short name is the same as three first letters of the team's name, for example, for the mentioned club it is "DIN", 2. or, the first two letters of the short name should be the same as the first two letters of the team's name, while the third letter is the same as the first letter in the hometown's name. For the mentioned club it is "DIB". Apart from this, there is a rule that if for some club $ x $ the second option of short name is chosen, then there should be no club, for which the first option is chosen which is the same as the first option for the club $ x $ . For example, if the above mentioned club has short name "DIB", then no club for which the first option is chosen can have short name equal to "DIN". However, it is possible that some club have short name "DIN", where "DI" are the first two letters of the team's name, and "N" is the first letter of hometown's name. Of course, no two teams can have the same short name. Help Innokenty to choose a short name for each of the teams. If this is impossible, report that. If there are multiple answer, any of them will suit Innokenty. If for some team the two options of short name are equal, then Innokenty will formally think that only one of these options is chosen.

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 1<=n<=1000 $ ) — the number of clubs in the league. Each of the next $ n $ lines contains two words — the team's name and the hometown's name for some club. Both team's name and hometown's name consist of uppercase English letters and have length at least $ 3 $ and at most $ 20 $ .

输出格式


It it is not possible to choose short names and satisfy all constraints, print a single line "NO". Otherwise, in the first line print "YES". Then print $ n $ lines, in each line print the chosen short name for the corresponding club. Print the clubs in the same order as they appeared in input. If there are multiple answers, print any of them.

输入输出样例

输入样例 #1

2
DINAMO BYTECITY
FOOTBALL MOSCOW

输出样例 #1

YES
DIN
FOO

输入样例 #2

2
DINAMO BYTECITY
DINAMO BITECITY

输出样例 #2

NO

输入样例 #3

3
PLAYFOOTBALL MOSCOW
PLAYVOLLEYBALL SPB
GOGO TECHNOCUP

输出样例 #3

YES
PLM
PLS
GOG

输入样例 #4

3
ABC DEF
ABC EFG
ABD OOO

输出样例 #4

YES
ABD
ABE
ABO

说明

In the first sample Innokenty can choose first option for both clubs. In the second example it is not possible to choose short names, because it is not possible that one club has first option, and the other has second option if the first options are equal for both clubs. In the third example Innokenty can choose the second options for the first two clubs, and the first option for the third club. In the fourth example note that it is possible that the chosen short name for some club $ x $ is the same as the first option of another club $ y $ if the first options of $ x $ and $ y $ are different.