Fool's Game

Time limit1sMemory limit128 MB

Problem

A card game often called "Fool's Game" is popular in Russia. Here we describe a version for two players.

A standard deck of 36 cards is used, and one suit is declared the trump suit.

The game is played in rounds. At the start of a round each player holds several cards: one player is the attacker (the starting player) and the other is the defender (the covering player).

The attacker begins by placing one or more cards of the same rank face-up on the table. The number of cards placed must not exceed the number of cards the defender currently holds. The defender must then cover every one of these cards by laying one of her own cards on top of it. A card X can cover a card Y when either:

  • X and Y have the same suit and X has the higher rank (ranks increase in the usual order: 6, 7, 8, 9, 10, J, Q, K, A); or
  • X is a trump and Y is not a trump (a trump can only be covered by a higher trump).

Once every card on the table is covered, the attacker may toss in additional cards to be covered. Each tossed card must have a rank that already appears among the cards on the table. The defender must cover the newly added cards, after which the attacker may toss in more, and so on. At no point may the attacker toss in more cards than the defender currently holds.

A round ends when either the defender cannot or chooses not to cover all of the uncovered cards, or the attacker cannot or chooses not to toss in more cards.

In the first case, when the defender declines to cover the uncovered cards, the attacker is given one final chance to toss in more cards. Each such card must have a rank already present on the table, and the number of uncovered cards on the table must not exceed the number of cards the defender currently holds. After that the defender loses the round and takes every card from the table into her hand. The attacker keeps the attacking role and starts the next round.

In the second case, when every card on the table is covered and the attacker cannot or chooses not to toss in more cards, the defender wins the round and all cards on the table are removed from the game. For the next round the two roles are swapped: the defender becomes the attacker and vice versa.

If, after a round ends, exactly one player has no cards left, that player wins the game. If both players run out of cards at the same time, the player who was the attacker in the final round wins.

Given the trump suit and the cards each player starts with, determine who wins the game if both players play optimally. Both players have full information about all cards in play.

Input

The first line contains two integers n1 and n2 — the number of cards held by the first and second player at the start of the round (1 ≤ n1, n2 ≤ 6) — followed by the trump suit, given as a single letter: 'S' for spades, 'C' for clubs, 'D' for diamonds, or 'H' for hearts.

The second line contains n1 card descriptions: the cards of the first player. Each card is written as its rank ('6'…'9', 'T' for 10, 'J' for Jack, 'Q' for Queen, 'K' for King, 'A' for Ace) immediately followed by its suit. The third line contains n2 card descriptions: the cards of the second player.

The first player is the attacker in the first round. All cards in the players' hands are distinct.

Output

Print "FIRST" if the first player wins the game, or "SECOND" if the second player wins.