Score : $200$ points
There are $N$ people numbered Person $1$, Person $2$, $\dots$, and Person $N$. Person $i$ has a family name $s_i$ and a given name $t_i$.
Consider giving a nickname to each of the $N$ people. Person $i$'s nickname $a_i$ should satisfy all the conditions below.
Is it possible to give nicknames to all the $N$ people? If it is possible, print Yes
; otherwise, print No
.
Input is given from Standard Input in the following format:
$N$ $s_1$ $t_1$ $s_2$ $t_2$ $\vdots$ $s_N$ $t_N$
If it is possible to give nicknames to all the $N$ people, print Yes
; otherwise, print No
.
3 tanaka taro tanaka jiro suzuki hanako
Yes
The following assignment satisfies the conditions of nicknames described in the Problem Statement: $a_1 =$ taro
, $a_2 =$ jiro
, $a_3 =$ hanako
. ($a_3$ may be suzuki
, too.)
However, note that we cannot let $a_1 =$ tanaka
, which violates the second condition of nicknames, since Person $2$'s family name $s_2$ is tanaka
too.
3 aaa bbb xxx aaa bbb yyy
No
There is no way to give nicknames satisfying the conditions in the Problem Statement.
2 tanaka taro tanaka taro
No
There may be a pair of people with the same family name and the same given name.
3 takahashi chokudai aoki kensho snu ke
Yes
We can let $a_1 =$ chokudai
, $a_2 =$ kensho
, and $a_3 =$ ke
.