A vocational preference test, unlike an aptitude test, seeks to identify careers that the candidate might find satisfying. Based on the answers to a slew of seemingly inane multiple-choice questions like the one below, the test determines which occupations suit the candidate's personality.
Which would you rather spend an afternoon doing?
(a) feeding chickens
(b) driving a race car
(c) watching The Simpsons on TV
(d) suntanning
(e) building a dog house
The input contains several test cases followed by a line containing 0. Each case begins with n, the number of questions in the test. n lines follow, each containing the names of five distinct activities, followed by the candidate's answer - one of the five alternatives. Each activity is named by a single upper case letter.
For each test case, output the sets, one per line. Output the elements of each set in alphabetical order, and output the sets in alphabetical order by their least element. The sets should together contain exactly the set of activities that appear in the input. Leave an empty line between test cases.
4 A B C D E C F C H I J J K B H I F I K C E B J K 0
A B C D E F H I J K