|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||9||9||4||100.000%|
Musical chairs is a game frequently played at children's parties. Players are seated in a circle facing outwards. When the music starts, the players have to stand up and move clockwise round the chairs. One chair is removed, and when the music stops the players all have to try to sit down on one of the chairs. The player who does not manage to sit down is out, and the game continues until there is just one player left, who is the winner.
The first line contains a single integer, N which is the number of players (1 < N <= 15). The next N lines have the names of the players. The length of player's name does not exceed 10.
The next line contains R, an integer which tells how many rounds are to be processed (0 < R < N). The next R lines each contain a pair of integers S and M, separated by a space. S is the number of the seat to be removed. Seats are numbered from 1 to the number of seats remaining in a clockwise direction.
M is the number of moves made before the music stops (0 < M <= 30). A move takes a player from one seat to the next in a clockwise direction. A move from the highest seat number takes a player to seat 1.
After each round has taken place, output a line
<name> has been eliminated.
where <name> is the name of the person who does not find a seat. This will be the person who would have ended up at the seat which was removed.
At the end of the specified number of moves, output a line which either says
<name> has won.
where a single player remains, or
Players left are <name list>.
where the game is not yet finished.
<name list> contains the name of each player not yet eliminated in the same order as in the input. The names are separated by spaces.
5 Anne Bill Chen Di Everet 4 3 6 2 8 1 5 2 6
Bill has been eliminated. Anne has been eliminated. Chen has been eliminated. Everet has been eliminated. Di has won.
6 Ferdinand Garcia Henrietta Isabel Jacob Kirstin 3 6 10 5 1 2 30
Garcia has been eliminated. Kirstin has been eliminated. Jacob has been eliminated. Players left are Ferdinand Henrietta Isabel.