Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 3472
Play Bridge

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Contract Bridge was invented in the 1920's and in the following decades it was popularised especially in the USA by Ely Culbertson. Bridge currently occupies a position of great prestige, and is more comprehensively organised than any other card game. There are clubs, tournaments and championships throughout the world.Because Contract Bridge is so popular that smallchen determines to learn it.

There are four players in two fixed partnerships. Partners sit facing each other. It is traditional to refer to the players according to their position at the table as North, East, South and West, so North and South are partners playing against East and West. The game is played clockwise.

A standard 52 card pack is used. The cards in each suit rank from highest to lowest: A K Q J 10 9 8 7 6 5 4 3 2. Suits rank as follows:spades, hearts, diamonds, clubs. For example, S-A > S-K , S-2 > H-A. Or we can regard { suit , number } as a pair.

The first step for bridge is bidding.A bid specifies a number of tricks and a trump suit (or that there will be no trumps). The side which bids highest will try to win at least that number of tricks bid, with the specified suit as trumps.

When bidding, the number which is said actually represents the number of tricks in excess of six which the partnership undertakes to win. For example a bid of "two hearts" represents a contract to win at least 8 tricks(turns) (8 = 6 + 2) with hearts as trumps.

After the first step, they play.The player to the left of the declarer leads to the first trick and may play any card.Play proceeds clockwise. Each of the other three players in turn must if possible play a card of the same suit that the leader played. A player with no card of the suit led may play any card. A trick consists of four cards, one from each player, and is won by the highest trump in it, or if no trumps were played by the highest card of the suit led. The winner of a trick leads to the next, and may lead any card.

To simplify this problem, we assume that every player will play the highest card regardless of the bid in hand during each trick, that is the leader will play the highest card and the rest will play the highest card he can play based on the rules. Smallchen knows the cards of every one, and he wants to know the result.

Input

There are multiple test cases.

The first line contains one integer T( 1 <= T <= 1000 ), indicating the number of cases.

For each case, the first line indicate the declarer( North, South, East or West ) and the bid.The bid contains two parts,one integer and one char.If the char equals 'S' means that spade is the trump suit. The others are the same. And 'N' means no trump suit. And then four blocks follow, each block is consisted of four lines, and the first integer n of each line indicate the number of cards of the corresponding suit, then n integers follow, 1 represents A , 11 represents J, 12 represents Q, 13 represents K and the others remain the same. Each block presents one player's cards.Their order is North->East->South->West. And each line presents the cards of each suit. Their order is spade->heart->diamond->club.

There is a blank line between two cases and two blocks.

Output

Output the result of each play in a single line. If the declarer side just wins the number of tricks what the bid needs, then output a "MAKE". If the number of tricks the declarer side wins is less than that the bid needs, then output a '-' mark and the number of tricks that they lost. On the other hand, if more than that the bid needs, output a '+' mark and the extra tricks they win.

Sample Input

```2
East 2 D
3 2 8 4
2 3 4
3 10 11 3
5 2 13 1 11 10

3 10 5 3
5 6 12 11 5 13
4 2 6 1 7
1 5

2 13 1
4 10 2 9 7
3 4 12 9
4 12 3 6 8

5 11 7 9 6 12
2 1 8
3 8 5 13
3 9 7 4

North 7 D
0
0
13 1 2 3 4 5 6 7 8 9 10 11 12 13
0

13 1 2 3 4 5 6 7 8 9 10 11 12 13
0
0
0

0
13 1 2 3 4 5 6 7 8 9 10 11 12 13
0
0

0
0
0
13 1 2 3 4 5 6 7 8 9 10 11 12 13
```

Sample Output

```+1
MAKE
```

Author: CHEN, Shimou
Contest: ZOJ Monthly, February 2011
Submit    Status