Both Xnby and Hekui like playing Chinese Chess. There are two sides: black and red in Chinese Chess. Each side take moves in turns. One day, they made a composition(Now, it\'s red\'s turn):
By the way, each side can only move the "Cannon"and the "Pawn".. The cannon can move in straight lines at any distance (from one cross to another) if no other chess pieces block its way. And the pawn can only move forward, one unit per turn. (For the red, top-bottom is forward, and for the black, bottom-top).
After the discussion,they all agree that only when one side, for example, the black cannon is forced to take a horizonal move which makes the red cannon can get to the hemline of the black, then the red wins (See the following figure).
So, they make a few rules:
- 1.The cannon can only move forward. If one side has to move the "cannon" to left or right, he loses. Notice that it doesn\'t change situation if a cannon moves backward, because the opposite side can move its cannon forward for the same distance.
- 2.Only the pawns which haven\'t crossed the river can move and the pawn can only move forward. The distance between each pair of pawns (one red, one black) can not be less than 1.
- 3.The winner only depends on the distance m and n(between the pair of cannons in the same vertical line counting from the left side), S1,S2,S3 (between the pair of pawns\' which not cross the river in the same vertical line counting from the left side).
(See the following figure)
Xnby and Hekui want to know: which side is the winner when each of them moves in the best strategy. To make it more interesting, m,n, S1,S2,S3 are not limited by Chinese Chessboard, in other words, Chessboard of this game is large enough.
4 1 2 2 1 0 0 1 1 1 -1