Filling a Board with N-Ominoes

For each case with piece size X and board R by C, decide whether Richard has an X-omino that blocks every tiling or Gabriel tiles the board anyway.

Medium6Game theoryGeometryMathNo attempts yetTime limit5sMemory limit512 MB

Problem

An N-omino is a flat shape made of NN unit squares joined edge to edge. A 1-omino is a single 1×11 \times 1 square. An N-omino is an (N-1)-omino with one more 1×11 \times 1 square attached along an edge. Two N-ominoes count as the same shape when one can be rotated or flipped onto the other.

The five possible 4-ominoes are shown below.

The five 4-ominoes

Some of the 108 7-ominoes are shown below.

Some of the 7-ominoes

Richard and Gabriel play the following game for fixed XX, RR and CC.

  1. Richard chooses one of the possible X-ominoes.
  2. Gabriel fills the R×CR \times C board with X-ominoes so that no cell is left empty and no piece sticks out. He must use at least one copy of the X-omino Richard chose, and every piece may be rotated or flipped.

Gabriel wins if he fills the board under these rules, and Richard wins if Gabriel cannot. Given XX, RR and CC, decide which player wins.

Input

The first line contains the number of test cases TT.

Each of the next TT lines contains XX, RR and CC, separated by spaces.

1T1001 \le T \le 100, 1X,R,C201 \le X, R, C \le 20

Output

For each test case, print one line in the form Case #x: y. Here xx is the test case number starting from 1. If at least one X-omino guarantees a win for Richard, yy is RICHARD. If no such X-omino exists, yy is GABRIEL.

Hint

In test case 1 of the sample, the only 2-omino Richard can choose is the 1×21 \times 2 rectangle. Two of those rectangles always fill a 2×22 \times 2 board, so Gabriel wins.

In test case 2 the only choice is again the 1×21 \times 2 rectangle. Wherever Gabriel puts it on a 1×31 \times 3 board, one cell is left over, so Richard wins.

In test case 3 Richard chooses the 4-omino shaped like a 2×22 \times 2 square. It has nowhere to go on a 1×41 \times 4 board, so Richard wins.

In test case 4 Richard can choose the straight 1×31 \times 3 tromino or the L shaped tromino. In both cases Gabriel fills the 2×32 \times 3 board with two copies of the same shape, so Gabriel wins.