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 MBAn N-omino is a plane figure made of N unit squares joined edge to edge. The 1-omino is a single 1×1 square. An N-omino is an (N-1)-omino with one more 1×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.

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

Cheolsu and Dongsu fix X, R and C, then play in this order.
If Dongsu covers the board under these rules, Dongsu wins. If he cannot, Cheolsu wins. Both players play optimally.
Given X, R and C, decide which player wins.
The first line contains the number of test cases T (1≤T≤64).
Each of the next T lines contains X, R and C separated by spaces (1≤X,R,C≤4).
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.
For X=2, R=2, C=2 the only 2-omino Cheolsu can pick is the 1×2 rectangle. Two of them cover the 2×2 board, so Dongsu wins.
For X=2, R=1, C=3 the only choice is again the 1×2 rectangle. The board has three cells, so wherever the piece goes one cell is left over and Cheolsu wins.
For X=4, R=4, C=1 Cheolsu picks the 4-omino shaped like a 2×2 square. It never fits on a board of width 1, so Cheolsu wins.
For X=3, R=2, C=3 Cheolsu must pick either the 1×3 bar or the L shape. In both cases two copies of the same shape cover the 2×3 board, so Dongsu wins.