DWITE Online Computer Programming Contest
January 2009
Problem 3
Secret party

You are in charge of putting together a guest list for a party, but because of the typical teenage high school drama situation, there is one particular person who you don't want to find out about the event (let alone invite). Being exceptionally paranoid, you want to take the safe side and not invite anyone who is friends with friends of the aforementioned person (or direct friends of that person, or that person). Luckily you have a computer, and there is a certain social network website that will tell you everybody's friends.

You want to invite your direct friends only, unless they match the restriction above.

The input file DATA3.txt will contain 5 sets of input. In each set, the first line is the number of friend relationships, 1 <= n < 100, followed by n lines in the format person1 person2. Each relationship is considered mutual (bidirectional).

You always have an ID of 1 and the target person always has an ID of 2. All person IDs are integer values. There will always be IDs 1 and 2 in the sets.

The output file OUT3.txt will contain 5 lines: a space-separated list of IDs of your direct friends to be invited, sorted in ascending order. In the special case where there is no one to invite, print "none", without quotes.

Note: You only trust yourself to stay quiet. If for some odd reason you are friends with person ID 2, that doesn't actually cancel the entire party.

Sample Input:
2
1 2
1 3
2
1 3
3 2
3
1 3
3 4
4 2
4
1 3
3 4
4 5
5 2
8
1 3
1 4
3 2
5 6
7 1
2 8
8 9
9 1

		        
Sample Output:
3
none
none
3
4 7