LIST | 프로그래밍의 벗 PivotOJ
PivotOJ

LIST

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2001 National Competition #2 - SeniorsBOJ 3291

문제

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.

예제

예제 1

입력
4
LOVE
UP
WINE
UP
WATER
DOWN
HATE
DOWN
출력
WATER
HATE
LOVE
WINE

예제 2

입력
4
HOTDOG
UP
HAMBURGER
DOWN
ICECREAM
SAME
FRENCHFRIES
DOWN
출력
HAMBURGER
FRENCHFRIES
ICECREAM
HOTDOG

예제 3

입력
5
HIGHHOPES
UP
LOWFEELINGS
UP
UPANDDOWN
DOWN
IAMSTILLSTANDING
DOWN
FOOLINGAROUND
DOWN
출력
UPANDDOWN
IAMSTILLSTANDING
FOOLINGAROUND
HGHHOPES
LOWFEELINGS
코드를 제출하려면 로그인하세요.