Tyrion Lannister is a master player of cyvasse, a game of strategy and war similar to chess. He has challenged
Bronn, the captain of his guard, during Joffrey Baratheon’s nameday celebrations. In his inebriated state,
Tyrion is finding it harder and harder to beat Bronn as the evening wears on. Unfortunately, he has staked
too much in his pride and it is imperative that he win all games to avoid humiliation.
Cyvasse is played with a grid of n x m cells (n rows and m columns), with tiles of grass, forest, water or
mountains covering each cell. Players have pieces occupying tiles corresponding to infantry, cavalry, artillery
and one dragon each. Players can attack their own pieces too. Tyrion decides to use his dragon to destroy an
entire row of the board at a time. Bronn being not so experienced, simply mirrors Tyrion’s tactics. However,
there is a catch. In subsequent moves, a player can only destroy a row with number of corresponding tile
position differing from that of the last destroyed row as an odd prime. Two tile positions differ if they one is
filled and other is empty. Eg. 1100011 and 0001000 differ at 5 positions which is odd prime. ‘1’ denotes a
filled position and ‘0’ denotes an empty position. Both of them mutually decide to concede when they have
no move left.
Given n, m and the state of each tile (occupied or unoccupied), does Tyrion have a winning strategy if he
takes he first move?
First line contains T , the number of test cases. T test cases follow.
First line of each test case contain 2 space separated integers n and m as specified above.
An nxm matrix follows denoting the initial state of the game. A ‘1’ denotes that the position is filled up. ‘0’
denotes an empty position
n <= 100
m <= 1000
For each test case, output on a separate line “YES” (quotes for clarity) if he has a winning strategy else
“NO” (quotes for clarity)
Sample Input :
Can someone please explain me a Test Case with the attack sequence. I’ve tried all possible combinations but failed