There are () piles of stones. Each pile has at least and at most stones in it. You are bored, and decide to play a game with the stones. The rules of this game are as follows:
- during a players turn, if there are no stones left, that player loses
- otherwise, a player may take any positive number of stones from any one pile (of course, you can't take stones from an empty pile, but if the pile has at least one stone, you can take the whole pile)
- if it's the very first turn of the game, the first player may choose to pass (that is, take stones from any pile)
Write a program to play this game against a computer AI. You always go first.
To take stones from pile , output P X
where and .
The AI will produce output in a similar fashion.
If you win, the AI will output 0 0
. Your program should terminate if you win or lose.
Input Specification
The first line of input will have .
The -th line will have the number of stones in pile .
Output Specification
Please flush your output properly.
Sample Interaction
>>>
denotes your output; don't actually print this out.
3
1
2
3
>>> 1 1
2 1
>>> 3 1
3 2
>>> 2 1
0 0
Explanation for Sample Interaction
Since the AI is unable to take a stone, you win.
Comments
AI should win after the first step of the player.