Filling a board with N-ominoes (Small)

Given polyomino size X and board size R by C, decide whether the first player can choose a shape that makes the board impossible to tile.

Medium5GeometryGame theoryBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

An N-omino is a plane figure made of NN unit squares joined edge to edge. The 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 congruent N-ominoes count as the same shape, so shapes that coincide after a rotation or a reflection are counted once.

There are five 4-ominoes.

The five 4-ominoes

There are 108 7-ominoes in total. Some of them are shown below.

Some of the 7-ominoes

Cheolsu and Dongsu fix XX, RR and CC, then play in this order.

  1. Cheolsu picks one X-omino.
  2. Dongsu places X-ominoes so that they cover the R×CR \times C board exactly, with no gap and no overlap. He must use at least one copy of the X-omino Cheolsu picked. He may mix X-ominoes of different shapes, and he may rotate or reflect each piece before placing it.

If Dongsu covers the board under these rules, Dongsu wins. If he cannot, Cheolsu wins. Both players play optimally.

Given XX, RR and CC, decide which player wins.

Input

The first line contains the number of test cases TT (1T641 \le T \le 64).

Each of the next TT lines contains XX, RR and CC separated by spaces (1X,R,C41 \le X, R, C \le 4).

Output

For each test case print one line in the form Case #x: y, where x is the test case number starting from 1.

If at least one X-omino makes Cheolsu win once he picks it, y is RICHARD. If no such X-omino exists, y is GABRIEL.

Hint

For X=2X = 2, R=2R = 2, C=2C = 2 the only 2-omino Cheolsu can pick is the 1×21 \times 2 rectangle. Two of them cover the 2×22 \times 2 board, so Dongsu wins.

For X=2X = 2, R=1R = 1, C=3C = 3 the only choice is again the 1×21 \times 2 rectangle. The board has three cells, so wherever the piece goes one cell is left over and Cheolsu wins.

For X=4X = 4, R=4R = 4, C=1C = 1 Cheolsu picks the 4-omino shaped like a 2×22 \times 2 square. It never fits on a board of width 1, so Cheolsu wins.

For X=3X = 3, R=2R = 2, C=3C = 3 Cheolsu must pick either the 1×31 \times 3 bar or the L shape. In both cases two copies of the same shape cover the 2×32 \times 3 board, so Dongsu wins.