Paweł i Gaweł 2

No attempts yetTime limit1sMemory limit128 MB

Problem

After settling who takes the upper floor of their new house, Paweł and Gaweł decide to play another game, this time for the right to use the attic.

They place NN piles in a row on the table, each holding at least 11 stone. Stones within a pile are indistinguishable. Starting with Paweł, the players move alternately. On a move, a player chooses either the leftmost remaining pile or the rightmost remaining pile and removes any number of stones (at least 11) from it.

The player who removes the last stone wins, and both players play optimally. Who earns the right to use the attic?

Input

The first line contains the number of test cases ZZ (1Z101 \le Z \le 10).

Each test case spans two lines. The first line holds the number of piles NN, and the second line holds the stone counts AiA_i of the piles from left to right, separated by spaces. (1N2001 \le N \le 200, 1Ai2001 \le A_i \le 200)

Output

For each test case, print the answer on its own line: P if Paweł can force a win no matter how Gaweł plays, otherwise G.