Breaking Plates
Eleni and Petros have in front of them two piles of plates. One pile has plates and the other has plates. The game proceeds as follows: players take turns either taking one plate from one pile and breaking it or taking two plates (one from each pile) and breaking them. The player who breaks the last plate wins. Eleni always starts the game. Given and , your program should determine whether the starting player (Eleni) wins or the second player (Petros) wins.
Input
A file named dishes.in contains an integer on the first line () indicating the number of repetitions. Then, pairs of numbers follow, each indicating the number of plates in the two piles, and (). These two numbers are separated by a single space.
Output
A file named dishes.out containing integers (one integer per line). The integer is if Eleni wins and if Petros wins. The output file should end with a newline character.
Examples
- For and , it is obvious that Eleni wins (she breaks both plates and finishes).
- For and , it is obvious that Eleni loses. Why: If Eleni breaks one plate from each pile, then Petros breaks the remaining two plates (one from each pile). If Eleni breaks one plate from one pile, then Petros breaks the other plate from the same pile, and then Eleni has only one option left to break one from the pile with two plates, and Petros breaks the other, winning.
- If and , Eleni wins. Why: Eleni breaks one plate from the pile with three plates, and Petros plays with piles of and . However, according to the previous example, the player who starts with piles of and always loses (thus Petros loses).
Example of Input - Output Data
STDIN (dishes.in)
2
2 3
2 2
STDOUT (dishes.out)
1
2
Maximum execution time: sec.
Comments