Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 1641
Analyse the Bridge Note

Time Limit: 2 Seconds      Memory Limit: 65536 KB

To analyse the notes of Bridge is a good method to improve our level. Here are some notes of it, you are supposed to output the result of each game.

Input

The note of Bridge has two parts, one is the "Promise" of the game, the other is a sequence of 52 cards, which represented the sequence of the 52 cards handed out by the players. The format of data is as follows:

[n][suit] ------ Promise of the game
[suit][m1] [suit][m2] [suit][m3] [suit][m4] ------ The sequence of the cards handed out
[suit][m5] [suit][m6] [suit][m7] [suit][m8]
...
[suit][m49] [suit][m50] [suit][m51] [suit][m52] ------ The sequence of the cards handed out

In the Promise:
[n] may be a number 1 -- 7, (n + 6) represents the turns the Banker must win in the game.
[suit] is the King suit of the game, may be "S", "H", "D" or "C", and "NT" meanse there's no King suit in this game.
In the Sequence:
Each one represents a card handed out by a player. [suit] is the suit of this card (in the range of {S, H, D, C}), and the [mi] is the point of this one (in the range of {A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2}).

For example:

3C
C6 H9 SK HJ
S7 CK SA SQ
CJ DA S2 CA
D7 H6 CT C4
H7 C9 C3 C8
ST S8 D4 DQ
S5 S4 H3 HQ
D6 C5 S6 DJ
S9 C2 HA H5
D2 HK C7 H8
DK SJ D9 S3
D3 D5 CQ DT
HT H2 D8 H4

"3C" is the Promise of the game, which means in this game the Banker must win 9 turns in all (3 + 6 == 9), "C"(Club) is the King suit. The next 13 line, 4 cards in each line represent the cards in each turn, according the order. Of course, the player who handed out the most powerful card in the last turn has to hand out first in this turn. The next player of the Banker hands out first in the first turn.

In each turn, the King suit is always more powerful than other suit of cards. The suit of the first card is always greater than other suit (except the King suit). If the suit is the same, then accord the sequence: A > K > Q > J > T > 9 > 8 > 7 > 6 > 5 > 4 > 3 > 2.

In each turn, the player who handed out the most powerful card wins this turn.

In the first turn in the example, the rivalries handed out C6 and SK, but the Banker handed out H9 and HJ. "C" is the King suit of the game, so the Banker didn't win in this turn. Then the rivalries also hand out first: S7 and SA, but one of the Banker hands out a CK, so the Banker win this turn, and hand out first in the third turn.

The Banker's purpose is that win at least (n + 6) turn, where n is the number in the Promise.

Proceed to the end of file.

Output

First output the Promise, then output the result of the game. If the number of turns the Banker wins exactly equals (n + 6), output "MK", else output "+x" or "-x", where x is the number of turns more or less than (n + 6).

Sample Input

3C
C6 H9 SK HJ
S7 CK SA SQ
CJ DA S2 CA
D7 H6 CT C4
H7 C9 C3 C8
ST S8 D4 DQ
S5 S4 H3 HQ
D6 C5 S6 DJ
S9 C2 HA H5
D2 HK C7 H8
DK SJ D9 S3
D3 D5 CQ DT
HT H2 D8 H4

1NT
D3 C8 D4 D8
H6 H7 C9 CK
CA DQ C5 D7
S3 D9 HJ SJ
CT S9 HQ D2
DT SK HK S6
C6 H5 H4 C4
C7 D6 SQ H3
C2 SA HA S8
C3 DA S2 CJ
H9 S7 D5 HT
S5 CQ S4 H8
H2 DK ST DJ

4D
S3 S2 ST H9
H6 S6 SA CJ
S7 C8 DQ DA
H8 C3 D8 C5
CQ SQ D7 SJ
H4 H5 HQ S5
S9 C4 DK DJ
D6 HT C6 CA
C2 C7 C9 CT
D3 D5 S4 HA
D4 D9 CK H7
HK DT H2 SK
HJ S8 H3 D2

Sample Output

3CMK
1NT+3
4D-2

Author: JIANG, Hao
Source: ZOJ Monthly, September 2003
Submit    Status