#K96292. Gary and Harry's Stone Game

    ID: 39054 Type: Default 1000ms 256MiB

Gary and Harry's Stone Game

Gary and Harry's Stone Game

In this problem, you are given two heaps of stones with counts (A) and (B) respectively. Two players, Gary and Harry, play the game where Gary always makes the first move. The game's winning condition is based on a bitwise XOR operation on the values of the heaps. Specifically, if (A \oplus B = 0) (i.e. the bitwise XOR of (A) and (B) equals zero), then the winner is Gary; otherwise, the winner is Harry.

This decision criterion might seem counter-intuitive compared to some classical impartial games, so pay careful attention to implement the condition exactly as described. Your task is to determine the winner for each test case provided in the input.

inputFormat

The input is read from standard input (stdin).

The first line of input contains an integer (T) ((1 \le T \le 10^5)), representing the number of test cases. Each of the following (T) lines contains two space-separated integers (A) and (B) ((0 \le A, B \le 10^9)), denoting the number of stones in each heap.

outputFormat

For each test case, output the name of the winner on a new line. Print "GARY" if (A \oplus B = 0), otherwise print "HARRY". All outputs should be written to standard output (stdout).## sample

4
2 3
5 4
1 1
8 8
HARRY

HARRY GARY GARY

</p>