In a party, we say that is a celebrity if everybody knows , but knows nobody. (We do not care if knows himself or herself.) Please write a program to tell if a party has a celebrity.
The party has persons, each with a first name and a surname . All those strings have the same length , and implicitly tell who knows who in a funny way. Given two characters and , let us define the “distance” between them as . Observe that . Now, given a first name and a surname , let us define the “total distance” between them as . Then, knows if and only if .
For instance, consider a small party with two persons with short names: Li Hu and No Hi. Since $d(`\texttt{\small L}', `\texttt{\small H}') = 4$ and $d(`\texttt{\small i}', `\texttt{\small i}') = 0$, we have $t(``\texttt{\small Li}'', ``\texttt{\small Hi}'') = 4 > 0$, so Li Hu does know No Hi. By contrast, $t(``\texttt{\small No}'', ``\texttt{\small Hu}'') = 0$, so No Hi does not know Li Hu.
Input consists of several cases. Every case begins with , followed by names (first name and surname). All the given strings have the same length . The first letter of each string is uppercase, the rest are lowercase. First names and surnames can be repeated, but the composition of them uniquely identifies one person. Assume and .
Print one line for every case. If the party has no celebrity, print
“No”. If the party has one celebrity, print his or her
name. If the party has more than one celebrity, print
“I should learn some logic”.
Input
2 Li Hu No Hi 2 John York Elsa Pope 4 Pam Kim Max Kim Ann Oak Ada Hay
Output
No Hi No Ann Oak