Party at Hali-Bula

No attempts yetTime limit1sMemory limit128 MB

Problem

Dear Contestant,

I'm going to have a party at my villa in Hali-Bula to celebrate my retirement from BCM. I wish I could invite all of my co-workers, but imagine how an employee could enjoy the party if they found their own boss among the guests! So I have decided not to invite both an employee and that employee's boss.

The organizational hierarchy at BCM is a tree: nobody has more than one boss, and there is exactly one employee with no boss at all (the Big Boss). Could you please write a program to determine the maximum number of guests I can invite so that no invited employee has their boss invited as well? I've attached the list of employees and the organizational hierarchy of BCM.

Best,
-Brian Bennett

P.S. I would also be very grateful if your program could indicate whether the set of invited people is uniquely determined when I invite the maximum number of guests under this condition.

Input

The input consists of several test cases. Each test case begins with a line containing an integer $n$ ($1 \le n \le 200$), the number of BCM employees. The next line contains the name of the Big Boss only. Each of the following $n - 1$ lines contains the name of an employee together with the name of that employee's boss, separated by a blank. Every name is a string of at least one and at most 100 letters. The input is terminated by a line containing a single $0$.

Output

For each test case, print a single line containing the maximum number of guests that can be invited under the required condition, followed by the word Yes or No depending on whether the set of guests achieving that maximum is unique.