## LCC '18 Contest 4 S5 - Durak

View as PDF

Points: 15
Time limit: 2.0s
Memory limit: 128M

Author:
Problem types

Durak (translation: fool) is a Russian card game commonly played by two players who take turns attacking each other. Each player has a hand of $$N$$ cards, and an attack happens as follows:

• The attacking player plays some card from his hand
• The defending player then needs to beat that card by playing a card of the same suit and higher rank, or a trump card (see note below).
• The attacking player can then continue the attack by playing a card that has the same rank as a card that has already been played.
• This process repeats until the attacking player cannot continue the attack or the defending player cannot beat a card.

Note: Each game designates one of the suits as the trump suit. A card from the trump suit is called a trump card. If a player attacks with a trump card, the defending player must play a trump card of higher rank to beat it.

For example, suppose the trump suit is spades, attacking player's hand is 7H, 7D, 3C and the defending player's hand is 8H, 3S, 6C. Then an example attack is:

1. Attacker plays 7H, which is beaten by 8H.
2. Attacker plays 7D, as a $$7$$ has already been played. It is beaten by 3S as it is a trump card.
3. Attacker plays 3C, as a $$3$$ has already been played. It is beaten by 6C.

Hence the defender would win this round. Given the hands of the attacker and defender, is it possible for the attacker to win the round?

#### Input Specification

The first line of input contains a single integer $$T$$ $$(1 \le T \le 10)$$, the number of rounds to be played. For each round, the first line contains an integer $$N$$ $$(1 \le N \le 10)$$, the number of cards in each player's hand, and $$S$$ ($$S$$ is either H, D, C, or S), the trump suit. The next two lines each contain $$N$$ card descriptions representing the attacker's and defender's hands, respectively. A card description consists of a number between $$1$$ and $$13$$ concatenated with either H, D, C, or S. No two players will have the same card and all cards will follow the standard playing card format.

#### Output Specification

For each round, output Takes if the attacker can win, or Beaten, if the defender always wins.

#### Sample Input

2
3 S
7H 7D 3C
8H 3S 6C
2 S
13H 3C
3S 6D

#### Sample Output

Beaten
Takes