Cutting Brownies

No attempts yetTime limit2sMemory limit256 MB

Problem

John Horton Conway (born 1937) is a British mathematician. He is well known for inventing the cellular automaton usually called the "Game of Life". This problem comes from a game Conway invented in the 1970s.

The game is played with a rectangular sheet of brownies fresh out of the oven. The players are Harry, who cuts only horizontally, and Vicky, who cuts only vertically. At the start there is a single piece made of B×DB \times D connected squares, where BB is the breadth of the sheet and DD is its depth.

On each turn a player picks one of the remaining pieces and, if a cut is possible, cuts it into two smaller pieces whose breadth and depth are both integers. A horizontal cut by Harry splits the depth of a piece into two positive integers, and a vertical cut by Vicky splits its breadth into two positive integers. Pieces may not be rotated before or after a cut. A player who cannot cut any remaining piece on their turn loses.

Look at a few examples. The simplest game is 1×11 \times 1. Neither Harry nor Vicky can move, so whoever starts loses. A 1×21 \times 2 sheet is a win for Harry no matter who starts, and for the same reason a 2×12 \times 1 sheet is a win for Vicky no matter who starts.

A 2×22 \times 2 sheet is a loss for whoever starts. If Vicky starts, her only move leaves Harry with 1×21 \times 2 and 1×21 \times 2, and once he cuts either piece Vicky is left with 1×11 \times 1, 1×11 \times 1, 1×21 \times 2 and no move at all. By symmetry Harry loses if he has to start.

Intuition suggests that Vicky tends to win when the sheet is broader than it is deep, since such a sheet allows more vertical cuts, but look at 3×23 \times 2. If Harry starts, his only possible move leaves Vicky with 3×13 \times 1 and 3×13 \times 1, which she wins. If Vicky starts, every move of hers leaves Harry with 1×21 \times 2 and 2×22 \times 2. Harry answers and leaves Vicky with 1×11 \times 1, 1×11 \times 1, 2×22 \times 2, which she eventually loses, because the two 1×11 \times 1 pieces allow no move and the 2×22 \times 2 game is lost by whoever moves in it first.

A 4×24 \times 2 sheet is a win for Vicky no matter who starts. If Harry starts, he runs out of moves after his first cut. If Vicky starts, her best move is to cut down the middle, leaving Harry with 2×22 \times 2 and 2×22 \times 2, which he loses because each 2×22 \times 2 game is lost by whoever moves in it first.

Given the initial size of the sheet and the name of the player who starts, write a program that decides whether the starting player has a strategy that forces a win.

Input

The first line contains an integer NN (1N101 \le N \le 10), the number of test cases. Each of the next NN lines holds one test case: two integers BB and DD and a string SS, separated by spaces. BB is the initial breadth of the sheet (1B5001 \le B \le 500), DD is its initial depth (1D5001 \le D \le 500), and SS is either Harry or Vicky, depending on who moves first.

Output

For each test case, print on one line whether the player who starts can force a win. Print the name of the starting player, followed by can win or cannot win.