Game – Mouse and Cheese
Input: Standard Input
Output: Standard Output
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 3x3 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 cheese. A
stick is represented using the coordinates of its end points. The lower left of
the grid is the origin (0, 0). The two sticks surrounding the cheese, in the
example above, 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”.
Input
The first line of 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 denotes the location of the mouse
and 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
1
<= S,C <= 9
S != C
0 <= R <= 12
For each case, all
the removed sticks will be distinct.
Output
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 samples for
exact format.
Sample Input |
Output for Sample Input |
3 1
2 1 1
1 1 0 1
4 0 7
2 2 1
2 1 3 2
2 2 3 |
Case
1: No Cheese! Case
2: SOHA Case
3: TARA |
Problemsetter: Sohel
Hafiz
Special Thanks:
Arifuzzaman Arif