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 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:
- Attacker plays
7H
, which is beaten by8H
. - Attacker plays
7D
, as a has already been played. It is beaten by3S
as it is a trump card. - Attacker plays
3C
, as a has already been played. It is beaten by6C
.
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 , the number of rounds to be played.
For each round, the first line contains an integer , the number of cards in each player's hand, and ( is either H
, D
, C
, or S
), the trump suit.
The next two lines each contain card descriptions representing the attacker's and defender's hands, respectively. A card description consists of a number between and 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
Comments