Problem G. Team star, Team moon

You see a group of children playing a seeming interesting game.

"Hi kids, what are you playing?" You asked.

"We have a judge. Other kids belong to team Star or team Moon. There are n kids in team Star and m kids in team Moon. Guess who is the judge then we'll tell you what game we're playing."

"Ok! Any tips?"

"You can ask questions about whether someone belongs to some team. You can't ask whether someone is judge. Team Star will always tell the truth, while team Moon will always lie, but the judge is naughty: he will tell the truth for the 1st, 3rd, 5th... time you ask him, and lie for the 2nd, 4th, 6th... time."

"Restrictions?"

"You cannot ask a person about himself. For example, you can't ask me: 'Are you Star?' And you can ask a person at most two questions, and these two questions can't be about the same person. For example, if you asked me whether Tom belongs to team Star, you cannot ask me whether Tom belongs to team Moon, because you're asking me about Tom twice."

"Ok! Then I'll tell you every one's role, not only who is judge."

Interaction Protocol

Your program should read from standard input, and write to standard output. After printing each line to the standard output, you should flush the output, by calling fflush(stdout) or cout << flush in C/C++, flush(output) in Pascal and System.out.flush() in Java. Please read general instructions for interactive problems for more information.

First, read the number of test cases T (1<=T<=100). For each test case, read two integers n and m in the first line (2<=n+m<=500).

Then issue one or more Ask command, followed by an Answer command.

CommandDescription
Ask C1 C2 TAsk child C1: Does C2 belong to team T? 1<=C1,C2<=n+m+1, and C1 should not be equal to C2. T=0 means Team Star, T=1 means Team Moon. Returns 1 if the answer is "Yes", 0 otherwise. You cannot ask a child about the same child twice.
Answer R1 R2 ... Rn+m+1Tell the children each child's role. 0 means Team Star, 1 means Team Moon, 2 means judge. This command does not return anything.

If your program violated any of these rules (bad format, invalid arguments etc), the server will exit immediately, and you will receive Protocol Violation (PV).

Protocol Limit

For each test case, you can ask a person at most two questions, otherwise you'll get Protocol Limit Exceeded (PLE).

Sample Interaction

1
1 1
           Ask 1 2 0
0
           Ask 2 1 0
1
           Ask 3 1 1
0
           Answer 2 1 0

Rujia Liu's Present 7: Hello, Interactive Problems!
Problemsetter: Rujia Liu
Source: Chinese Olympiad in Informatics 2002
Special thanks: Yiming Li, Ziqing Mao (both are original alternative solution writers), Md. Mahbubul Hasan