A pack of playing cards has 52 cards, divided into suits and, within each suit, into denominations. The suits are, from lowest to highest, Clubs, Diamonds, Hearts and Spades, abbreviated C, D, H and S. The 13 denominations (face values) are, from lowest to highest: 2, 3, 4, 5, 6, 7, 8, 9, 10 (written T), Jack (J), Queen (Q), King (K) and Ace (A).
A higher card beats a lower card of the same suit, but normally does not beat any card of a different suit. The exception is the trump suit: if a suit is designated as trump, then any card of that suit beats any card of any other suit.
A simplified version of the old card game Hearts is played as follows.
The dealer deals the cards clockwise, one at a time and face down, to four other players and to himself. Dealing starts with the player on the dealer's left, who therefore receives the 1st card, then the 6th, and so on; the dealer receives the 5th card, then the 10th, and so on. Once every player holds 10 cards, two cards remain. These two are turned face up, and the suit of the card with the higher denomination becomes the trump suit. If the two cards have equal denomination, the higher-ranking suit becomes trump.
A game consists of 10 tricks, each made up of 5 cards, one from every player. In each trick one player leads, i.e. plays a card face up on the table; the other players then follow in clockwise order. The player on the dealer's left leads the first trick; thereafter the winner of each trick leads the next one.
A player must follow suit if possible, i.e. play a card of the same suit as the card led. If he cannot follow suit, he must trump (play a card of the trump suit). If he cannot trump either (he holds no trump), he discards a card. If any trump was played in a trick, the highest trump wins it; otherwise the highest card of the led suit wins it. The winner takes all five cards of the trick.
The players use the following fixed strategies:
After all tricks have been played, each player looks at the tricks he has won and scores the face value of every Heart in them (Jack counts 11, Queen 12, King 13 and Ace 14). Simulate the game and report each player's score.
The input consists of a series of decks. Each deck is given on four lines that hold its 52 cards in dealing order (13 cards per line, separated by single spaces). The input is terminated by a line containing a single #.
For each deck, output one line with 5 numbers: the players' scores, starting with the dealer and continuing clockwise through the other four players. Each score is right-justified in a field of width 3.