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 N piles in a row on the table, each holding at least 1 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 1) from it.
The player who removes the last stone wins, and both players play optimally. Who earns the right to use the attic?
The first line contains the number of test cases Z (1≤Z≤10).
Each test case spans two lines. The first line holds the number of piles N, and the second line holds the stone counts Ai of the piles from left to right, separated by spaces. (1≤N≤200, 1≤Ai≤200)
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.