Bakugan

No attempts yetTime limit1sMemory limit128 MB

Problem

Mark and Leti love to play with Bakugan balls. These balls are small plastic spheres, each holding a tiny monster toy inside. When dropped on the ground a Bakugan ball pops open with an incredible sound, releasing a fearsome Bakugan monster.

There are 10 different monsters. Mark and Leti ranked them by ugliness and assigned each monster a distinct integer from 1 to 10.

A game consists of $R$ rounds. In each round:

  • both players drop one ball simultaneously;
  • each player earns points equal to the integer assigned to the monster released by their ball;
  • the first — and only the first — player who releases the same monster in three consecutive rounds earns 30 additional points. If both players first meet this condition in the very same round, then nobody earns the extra points.

The 30-point bonus is awarded at most once during the whole game, to whichever player reaches three identical consecutive monsters earliest.

The winner is the player who accumulates more points. Determine the winner of each game.

Input

The input contains several test cases. Each test case is described using three lines:

  • the first line contains an integer $R$, the number of rounds of the game ($1 \le R \le 10$);
  • the second line contains $R$ integers $M_i$, the monsters released by Mark in each round ($1 \le M_i \le 10$, $1 \le i \le R$);
  • the third line contains $R$ integers $L_i$, the monsters released by Leti in each round ($1 \le L_i \le 10$, $1 \le i \le R$).

The input ends with a line containing a single 0, which must not be processed.

Output

For each test case, print a single line containing one character that represents the result of the game:

  • uppercase M if Mark wins,
  • uppercase L if Leti wins,
  • uppercase T if the game is a tie.