시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 268 | 9 | 4 | 5.797% |
Little Michael lives in a small country and likes to watch a TV music show which is emitted every Sunday afternoon. It presents the same songs every week and, according to votes, displays popularity list of those songs.
Michael played too long with his friend one Sunday and failed to see new popularity list. He was sad, but he soon realized that he would be able to at least partially reconstruct the popularity list next week. Apart from the positions of songs, a list contains information about change of positions of all songs with regard to their last week’s positions. More precisely, each song is given a mark indicating whether that song stayed at same position, gained or lost popularity since last week.
Write a program that will using given popularity list help Michael to determine one possible last week’s popularity list.
The first line of input file contains an integer N, 1 ≤ N ≤ 100, number of songs on popularity list.
Next N blocks describe a popularity list. A block consists of two lines. First line of ith block contains name of ith song. A name of a song consists of at most 100 uppercase letters of English alphabet. Second line of a block contains one of three words: UP (a song went up on a list), DOWN (a song went down on a list) or SAME (position stayed the same), describing a change on a list with respect to last week’s list.
The output file contains one possible popularity list from last week in N lines.
Each line should contain name of a song so that ith line contains name of ith song on a list.
Note: A solution needs not to be unique, but there always will be at least one solution for each test data.
4 LOVE UP WINE UP WATER DOWN HATE DOWN
WATER HATE LOVE WINE
4 HOTDOG UP HAMBURGER DOWN ICECREAM SAME FRENCHFRIES DOWN
HAMBURGER FRENCHFRIES ICECREAM HOTDOG
5 HIGHHOPES UP LOWFEELINGS UP UPANDDOWN DOWN IAMSTILLSTANDING DOWN FOOLINGAROUND DOWN
UPANDDOWN IAMSTILLSTANDING FOOLINGAROUND HGHHOPES LOWFEELINGS