Boring Game
Time limit4sMemory limit512 MB
Decide the winner of a coin-flipping game on a huge N by N board where each move flips a rectangle whose bottom-right corner is heads, with heads cells given as a union of M rectangles.
- Level
Hard8 of 10
- Topics
- Game theory, Combinatorics, Math, Geometry
- Solved
- No attempts yet
Problem
Yong Chol is playing a game with his brother. The game board is an grid. Each cell of the grid contains a coin. Each coin is either heads up or tails up. The players take turns flipping coins. In each turn, the player selects a cell () with a coin heads up, and also two integers and (, ). After that, the player looks at the rectangle of cells with its opposite corners containing cells and , and flips all coins in this rectangle, changing heads to tails and vice versa.
The player who cannot make a move loses the game.
The game with his little brother is so boring for Yong Chol that he wants to finish it immediately. But before doing that, Yong Chol wants to know who will win if the two players play optimally from now on. The board may be rather large, so its current state is given as a list of rectangles such that their union represents the cells with a coin heads up, and all other cells contain a coin tails up. Yong Chol is to take the next move. Can you help him find out who will win?
Input
The first line of input contains an integer , the number of test cases ().
Each test case starts with a line containing two integers: , the size of the board, and , the number of rectangles (, ).
Each of the next lines contains four integers , , , and : the coordinates of the two opposite corners of the rectangle (, , ).
The total sum of over all test cases will not exceed . For at least percent of the test cases, will be smaller than .
Output
For each test case, if Yong Chol wins the game, print "Yong Chol", otherwise print "Brother".