| Codeforces Round 1045 (Div. 2) |
|---|
| Finished |
This is an interactive problem.
You are given $$$n$$$ boxes, indexed from $$$1$$$ to $$$n$$$. The boxes look identical, but each one has a hidden power value $$$a_i$$$, which is either $$$1$$$ or $$$2$$$.
You want to determine the power value of each box. To do so, you conduct the following experiment. Initially, the $$$i$$$-th box is placed at coordinate $$$i$$$ on a number line ($$$1 \le i \le n$$$).
You are allowed to perform the following two types of queries:
Your task is to determine the power value of each box using no more than $$$\left\lceil \frac{3n}{2} \right\rceil$$$ queries in total, counting both swap and throw queries.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 500$$$). The description of the test cases follows.
The first and the only line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$) — the number of boxes.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.
The interaction for each test case begins by reading the integer $$$n$$$.
To make a query, output a line in one of the following formats:
Note that queries are case sensitive.
Once you have determined the power value of each box, output a line in the following format:
Note that submitting the final answer with the previous query does not count towards the limit of $$$\left\lceil \frac{3n}{2} \right\rceil$$$ queries.
If your program exceeds $$$\left\lceil \frac{3n}{2} \right\rceil$$$ queries in one test case, your program must terminate immediately to receive the verdict Wrong Answer. Otherwise, it may receive any other verdict.
After outputting a query, do not forget to output the end of the line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
The interactor is non-adaptive; the power values of the boxes remain constant throughout the interaction.
Hacks
To hack, use the following format.
The first line should contain a single integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$) — the number of boxes.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le 2$$$) — the power value of each box.
The sum of $$$n$$$ over all test cases should not exceed $$$1000$$$.
2 4 2 3 3 2 2 1
throw 2 swap 3 throw 2 throw 1 ! 2 1 2 1 throw 1 swap 1 throw 1 ! 1 2
Below is the interaction process in the example:
| Solution | Jury | Explanation |
| 2 | There are $$$2$$$ test cases. | |
| 4 | There are $$$4$$$ boxes in the first test case. The hidden power values are $$$a = [2,1,2,1]$$$. | |
| throw 2 | 2 | Throw a ball at the box located at coordinate $$$2$$$. The ball travels through coordinates $$$2 \to 3 \to 5$$$ and stops at coordinate $$$5$$$, so the response is $$$2$$$. |
| swap 3 | Swap the boxes located at coordinate $$$3$$$ and $$$4$$$. Now box $$$3$$$ is located at coordinate $$$4$$$ and box $$$4$$$ is located at coordinate $$$3$$$. | |
| throw 2 | 3 | Throw a ball at the box located at coordinate $$$2$$$. The ball travels through coordinates $$$2 \to 3 \to 4 \to 6$$$ and stops at coordinate $$$6$$$, so the response is $$$3$$$. Note that the response is different because of the swap. |
| throw 1 | 3 | Throw a ball at the box located at coordinate $$$1$$$. The ball travels through coordinates $$$1 \to 3 \to 4 \to 6$$$ and stops at coordinate $$$6$$$, so the response is $$$3$$$. |
| ! 2 1 2 1 | The solution concludes that the power values are $$$[2,1,2,1]$$$. | |
| 2 | There are $$$2$$$ boxes in the second test case. The hidden power values are $$$a = [1, 2]$$$. | |
| throw 1 | 2 | Throw a ball at the box located at coordinate $$$1$$$. The ball travels through coordinates $$$1 \to 2 \to 4$$$ and stops at coordinate $$$4$$$, so the response is $$$2$$$. |
| swap 1 | Swap the boxes located at coordinate $$$1$$$ and $$$2$$$. Now box $$$1$$$ is located at coordinate $$$2$$$ and box $$$2$$$ is located at coordinate $$$1$$$. | |
| throw 1 | 1 | Throw a ball at the box located at coordinate $$$1$$$. The ball travels through coordinates $$$1 \to 3$$$ and stops at coordinate $$$3$$$, so the response is $$$1$$$. |
| ! 1 2 | The solution concludes that the power values are $$$[1,2]$$$. |
Empty lines in the example input and output are given only for better readability; you don't need to output them in your solution.
Note that in the first test case, the given queries are in fact insufficient to uniquely determine the power values; they are given only to illustrate the input/output format.
| Name |
|---|


