Game: Mouse and Cheese
SOHA and TARA have recently invented a new game called “Mouse and Cheese”. As the name suggests, this game involves a mouse searching for a piece of cheese. The game is played on a 3 × 3 board as shown in the diagram below. Each cell is uniquely numbered with an integer between 1 and 9. The board contains 12 sticks (the blue lines in the diagram).
Initially, a mouse and a piece of cheese are placed on two different cells. In the example to the right, the mouse is placed on “cell 8”, and the cheese is placed on “cell 3”.
The rule of the game goes like this: It's a two-player game where the players make moves alternately. SOHA, being player 1, goes first. In each move, the player selects a stick and throws it away. After each move, if the mouse can reach the cell containing the cheese without touching any of the remaining sticks, then that player is declared as the winner. If both play perfectly, who wins?
Before the game starts, some of the sticks are removed. You will be given the coordinates of these sticks and the cell numbers of the mouse and the cheese. A stick is represented using the coordinates of its end points. The lower left of the grid is the origin (0, 0). In the example above, the two sticks surrounding the cheese has coordinates “2 0 2 1” and “2 1 3 1”. Note that the end points of a stick can be given in any order. That is “2 0 2 1” could be given as “2 1 2 0”.
The first line of the input is an integer T (T < 1000) that determines the number of test cases. Each case starts with 3 integers S, C, and R. S and C denote the location of the mouse and the cheese, respectively. Each of the next R lines contains 4 space-separated integers that give the coordinates of the sticks removed from the board before the start of the game.
Notes and constraints:
For each case, output the case number first, starting with 1, followed by the name of the player who wins. If the mouse can already reach the cheese before the game starts, output “No Cheese!” instead. Look at the sample output for exact format.
Output for Sample Input
|University of Debrecen; Faculty of Informatics; v. 03/01/2019|