Line up the Band

Description

Ms. Lorsong had been working with some members of the student band all day trying to get everyone positioned just right. Finally, she had everyone lined up just the way she wanted; but she knew sh couldn't just remember their positions. So, she gave each student a sheet of paper and asked each of them to write down his/her name and the name of the student to the immediate left. Naturally, the student on the left end of the line couldn't do this, so she did nothing.

Mr.s Lorsong thought that if she carefully collected the papers she would be able to reconstruct the line order (and she was right). However, she wasn't very careful and collected all the sheets in a basket (where they became thoroughly scrambled). She then had the information from the sheets transferred to a file. Your job is to read the file and display the reconstructed band lineup by listing the names of the students in order from right to left. You man assume that there are no more than 100 students in the band.

Input Specification

The input file BAND.NAMES contains a number of records. Each record consists of two names, each up to 8 characters long, padded with blanks if necessary. For Example, a record may contain the characters
Dave    Cathy   
The first name is the person who wrote the sheet; the second is the name of the student to that person's left. All student names are unique.

Output Specification

A list of names of the band in the correct order. The list should contain a single name per line.

Sample Input

Bob     Steve
Dave    Cathy
Steve   Dave
Ann     Bob

Sample Output

Ann
Bob
Steve
Dave
Cathy

This problem was from the Spring 1995 PACISE contest.