October 2012
Problem 3
Costume Party

Alice wants to hold a costume party for this Halloween. To make things interesting, and to prevent potential fights, she decided to make sure that all her friends will dress up in different costumes for the party. How she does this is by calling her friends one by one and asking them what they were planning on wearing for the party. If they were planning on wearing a costume that someone Alice has already spoken to was planning on wearing, then Alice tells them to wear something else. Being her best friend, she asks you to keep track of the friends she asks to wear something else (in case they need a reminder later on).

The input file DATA3.txt will contain 5 test cases. Each test case will start with a number 1 <= N <= 20, a number of friends Alice will call, followed by N lines - a pair of words, a friend's name and their costume (each one word).

The output file OUT3.txt will contain 5 lines: lists of friends that were asked to change costumes, in the order that they were called. Each list will be a single line, names separated by spaces. If a list is empty, print SPOOKY instead.

Note: since the judge checks if your line is an exact match, make sure not to end the list with an extra space. That is, the first sample is "jim sam" not "jim sam ".

Sample Input (first 2 shown):
bob casper
carrie scooby
jim casper
sam casper
tommy mummy
billy reaper
jim casper
Sample Output (first 2 shown):
jim sam