Squid Game

View as PDF

Submit solution


Points: 1
Time limit: 1.5s
Memory limit: 256M

Problem types

Jim Carrey is a known squid fan. One Christmas when he was alone and bored he decided to punish every squid hater in the world. He rounded up \(\mathbf{t}\) number of men named Şehmettin(as it turns out almost all squid haters are called Şehmettin) and 1 named Mahmut and forced them to play the Squid Game. Jim Carrey watched them to see what they would do. Soon the Şehmettins started introducing themselves "I'm Şehmettin", "I'm Şehmettin", "I'm Şehmettin". Your job as an employee of Jim Carrey is to watch Mahmut very carefully. Would he be frightened and disoriented in a world of Şehmettins or would he become the Squid Game champion?

In squid game, there are 2 piles of marbles. In one turn a player has to make 1 move. There are 2 types of moves:

  • Take any positive number of marbles from 1 pile.
  • Take the same positive number of marbles from both piles.

If your opponent does not have any marbles left at the start of their turn you win.

Squid haters have the power to play the squid game optimally.

Mahmut is the 1st player to make a move in all \(\mathbf{t}\) games.

Input

  • The first line contains 1 integer:
    • \(1\leq\mathbf{t}\leq5\times10^4\) (Number of Mahmut's matches)
  • The \(\mathbf{t}\) consecutive lines contain \(\mathbf{2}\) integers each:
    • \(0\leq a,b\leq10^6\) (number of marbles in 1st and 2nd piles)

Output

For every \(\mathbf{t}\) query

  • If the Mahmut is going to win print T (as in True)

  • If the Mahmut is going to lose print F (as in False)

Example

Input:

4
0 0
4 4
1 2
0 3

Output:

F
T
F
T

Explanation:

Mahmut starts every game.

  • 0 0:
    F because at the start of first turn there are no marbles in either of the heaps so first player loses.

  • 4 4:
    T because first player can take 4 marbles from both heaps and win easily.

  • 1 2:
    F because after the first turn there will be [0,2],[0,1],[1,1],[1,0] marbles left. So, the second player can finish the marbles in that turn.

  • 0 3:
    T because first player can take 3 marbles from first heap and win easily.