By Ricardo Anido Brazil
Drop Out is the name of a simple card game which is played with a normal deck of 52 cards. Cards are ordered by rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jockey, Queen, King), with Ace being the smallest and King the largest value. Card suits are disregarded. Players (at least two) sit around a table and a shuffled deck is put in the center of the table, card faces down. At the start of the game, all players are “active”. The game proceeds in rounds. In each round, active players are dealt one card from the deck, in clockwise direction regarding their sitting positions. The players who are dealt the smallest card in the round drop out of the game and become inactive. Notice that up to four players may drop out at each round. The game ends when there remains one only active player, which is the winner. If the entire deck is played out before a round finishes, the game is over and all active players at the beginning of this last round are winners.
Given the number of players, their names and a shuffled deck of cards, you must write a program to simulate the game and determine the winner or winners.
The input contains several test cases. Each test case consists of six lines. The first line contains an integer N , indicating the number of players in the game (2 ≤ N ≤ 20). The second line contains a list of player names, separated by spaces. A player name is composed of at most 16 letters from the English alphabet (from 'A' through 'Z' and 'a' through 'z'). Cards are dealt to players in the order given by the list. The next four lines contain the description of the shuffled deck. Card ranks are represented by integers from one to thirteen (1, 11, 12 and 13 denote respectively Ace, Jockey, Queen and King cards). The deck is described in four lines of thirteen integers each, separated by a single space. The deck is listed from top to bottom, so the first card dealt is the first card listed. The end of input is indicated by N = 0.
The input must be read from standard input.
For each test case in the input your program must produce one line of output, containing the name of the winner or winners. The list of winners must appear in same order given in the input, and each name must be followed by a space.
The output must be written to standard output.
|Sample Input||Sample Output|