Time limit
1s
Memory limit
128 MB
Many girls at Pascal High School wear earrings that are not allowed by the school rules. Whenever Vice Principal Sneddon sees long, dangling red earrings, he confiscates them.
The vice principal made a numbered list of the girls whose earrings were confiscated. On the back of each confiscated earring, he wrote the girl's number and either A or B, chosen arbitrarily.
After all regular classes and after-school detentions end, the girls visit the vice principal to get their earrings back. Unfortunately, one day he lost the envelope containing the earrings, and one earring could not be found.
Tell the vice principal the name of the angry girl who did not get her earring back.
The input consists of several numbered scenarios. Scenario numbers start at 1 and increase by 1 in input order. Each scenario is given as follows.
n of girls whose earrings were confiscated. (1 ≤ n ≤ 100)n lines contain the girls' names, one per line. Each name has length at most 60 characters.2n - 1 lines each contain a girl number and the letter A or B, separated by a space. The number matches the order of the vice principal's list, so 1 means the first girl whose earrings were confiscated. A girl's number appears at most twice, and when it appears a second time, it is paired with the other letter. The first record for a number represents confiscation, and the second record represents return.A final line containing 0 ends the input. Do not process this line.
For each scenario, output one line containing the scenario number and the name of the girl who did not get her earring back, separated by one space.