tz

The TZIANSITZI game, which translated means "picking stones", is a popular game from China. Two players alternate picking up stones from two piles. For each move, a player can only pick up the same number of stones from both piles or any number of stones from one pile. The winner is the player that also takes the last stone.

Task

Test if, for a given configuration, the first player has or doesn't have a win strategy and if he does, program the moves of the first player, with the moves of the second player being read from the keyboard.

Input Data

The program doesn't read data from any file.

Output Data

The program won't write data to any file.

Interaction

Our program will interact with a commission program running in parallel. For each test-case, your program will have to solve a series of tests. For each test-case the interaction has the following format:
1. Your program reads a line from standard input, containing
two positive integers, n m, separated by a space (n is the number of stones from the first pile, m is the number of stones from the second pile for that test). If n and m are zero, that means that the test-case is over.
2. If the test-case is not over, your program will determine if the first player has or doesn't have a sure win strategy. If positive, a line containing only value 1 will be written. If not, (meaning if the first player doesn't have a sure win strategy) a line containing only value 0 (zero) will be written, followed by a line containing the word DONE.
3.
If the first player has a sure win strategy, your program will execute a number of rounds. A round consists of writing a line to standard output, which describes the move executed by the first player in that round. A move is described by the number of the pile the player is picking the stones from (1 for the first pile, 2 for the second pile, and 3 for both piles), followed by a space, and then by a non-zero positive integer representing the number of stones picked up. Then, a line will be read from standard input describing the move executed by the second player (the move being specified the same way ). When your program has executed the last move, it displays a special line, containing only the word DONE

Scoring

Your program will be scored for the current test-case only if it correctly solved all the tests contained in that test-case.
Your program receives 0 points for a test in the following cases:
- during a round, it displays the number of a move that cannot be executed at that time;
- it displays that the first player has a sure win strategy when the first player doesn't (or vice-versa);
- when the first player has a sure win strategy, your program doesn't win;
- the display format for the problem is not respected.

Programming Instructions

C/C++ programmers must execute flush after they finished writing a complete line to output. This is also valid for the line containing DONE

For programs written in C++ using iostreams, the following sequence will be used for reading from standard input and writing to standard output:
cin>>x;
cout<<op<<'\n'<<flush;

For programs written in C using scanf and printf, the following sequence will be used for reading from standard input and writing to standard output:
scanf ("%d", &x);
printf("%d\n",op); fflush (stdout);

For programs written in Pascal the following sequence will be used for reading from standard input using readln, and for displaying a line writeln will be used:
readln(x);
writeln(op);

Constraints

1 <= n <= 1016
In a test set there are no more than 7 tests.

Interaction Example

Move Meaning

Reads 1 2
Writes 0
Writes DONE
Reads 5 6
Writes 1
Writes 2 3
Reads 1 1
Writes 3 2
Reads 3 1
Writes 1 1
Writes DONE
Reads 0 0

n=1, m=2
The first player doesn't have a sure win strategy
The first test is over
n=5, m=6
The first player has a sure win strategy
The first player picks up 3 stones from pile 2
The second player picks up 1 stone from pile 1
The first player picks up 2 stones from both piles
The second player picks up 1 stone from both piles
The first player picks up 1 stone from pile 1
The test is solved
The test-case is over

Time limit: 0.1 seconds/test

prof. Emanuela Cerchez
"Grigore Moisil" Iaşi IT High School
Contact:emanuela.cerchez@gmail.com