| Codeforces Round 1136 (Div. 1) |
|---|
| Finished |
This is an interactive problem.
There is a significant difference between the easy and hard versions of this problem. Please read the statement carefully.
Yukari Yakumo has placed $$$n$$$ boundary stones on the ground, each with power $$$1$$$ or $$$2$$$. You do not know the powers of the stones; you only know $$$n$$$.
In each test case, you may write a spell $$$s$$$ consisting of the characters + and - ($$$1 \le |s| \le 999$$$) and give it to Yukari. Yukari chooses a prefix of $$$s$$$ (possibly empty) and then performs every character of this prefix in order.
When performing the $$$i$$$-th character of the prefix, Yukari chooses a stone that is currently on the ground. The chosen stone changes as follows:
If there is no stone on the ground, the remaining characters cannot be performed, and the number of stones on the ground at that moment is $$$0$$$.
Yukari wants the number of stones on the ground after performing the chosen prefix to be as large as possible. If several prefixes achieve this maximum, she chooses the shortest of them and tells you its length $$$k$$$.
Knowing $$$k$$$, you have to output the sum of the initial powers of the $$$n$$$ stones.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 100$$$) — the number of stones.
For each test case, after reading $$$n$$$, you should begin the interaction and find the answer before proceeding to the next test case.
The interaction for each test case is as follows:
After printing each query do not forget to output the end of line and flush$$$^{\text{∗}}$$$ the output. Otherwise, you will get Idleness limit exceeded verdict.
If, at any interaction step, you read $$$-1$$$ instead of valid data, your solution must exit immediately. This means that your solution will receive Wrong answer because of an invalid query or any other mistake. Failing to exit can result in an arbitrary verdict because your solution will continue to read from a closed stream.
The powers of the stones are fixed before the interaction starts and do not depend on the spell.
Hacks are disabled in this problem.
$$$^{\text{∗}}$$$To flush, use:
< 2 < 2 > +- < 0 > 2 < 3 > +- < 1 > 5
In the first test case, $$$n = 2$$$ and the powers of the stones are $$$1$$$ and $$$1$$$ (your program does not know this, but the interaction depends on it). You print +-.
In the second test case, $$$n = 3$$$ and the powers of the stones are $$$1$$$, $$$2$$$, $$$2$$$. You print +-.
| Name |
|---|


