Problem: cf1292_e
Difficulty: medium
Categories: greedy, data structures
Time limit: 2000 ms, memory limit: 256 MB

MisoilePunch♪ - 彩

This is an interactive problem!

On a normal day at the hidden office in A.R.C. Markland-N, Rin received an artifact, given to her by the exploration captain Sagar.

After much analysis, she now realizes that this artifact contains data about a strange flower, which has existed way before the New Age. However, the information about its chemical structure has been encrypted heavily.

The chemical structure of this flower can be represented as a string $p$. From the unencrypted papers included, Rin already knows the length $n$ of that string, and she can also conclude that the string contains at most three distinct letters: "C" (as in Carbon), "H" (as in Hydrogen), and "O" (as in Oxygen).

At each moment, Rin can input a string $s$ of an arbitrary length into the artifact's terminal, and it will return every starting position of $s$ as a substring of $p$.

However, the artifact has limited energy and cannot be recharged in any way, since the technology is way too ancient and is incompatible with any current A.R.C.'s devices. To be specific:

* The artifact only contains $\frac{7}{5}$ units of energy.
* For each time Rin inputs a string $s$ of length $t$, the artifact consumes $\frac{1}{t^2}$ units of energy.
* If the amount of energy reaches below zero, the task will be considered failed immediately, as the artifact will go black forever.

Since the artifact is so precious yet fragile, Rin is very nervous to attempt to crack the final data. Can you give her a helping hand?

Interaction

The interaction starts with a single integer $t$ ($1 \le t \le 500$), the number of test cases. The interaction for each testcase is described below:

First, read an integer $n$ ($4 \le n \le 50$), the length of the string $p$.

Then you can make queries of type "? s" ($1 \le |s| \le n$) to find the occurrences of $s$ as a substring of $p$.

After the query, you need to read its result as a series of integers in a line:

* The first integer $k$ denotes the number of occurrences of $s$ as a substring of $p$ ($-1 \le k \le n$). If $k = -1$, it means you have exceeded the energy limit or printed an invalid query, and you need to terminate immediately, to guarantee a "Wrong answer" verdict, otherwise you might get an arbitrary verdict because your solution will continue to read from a closed stream.
* The following $k$ integers $a_1, a_2, \ldots, a_k$ ($1 \le a_1 < a_2 < \ldots < a_k \le n$) denote the starting positions of the substrings that match the string $s$.

When you find out the string $p$, print "! $p$" to finish a test case. This query doesn't consume any energy. The interactor will return an integer $1$ or $0$. If the interactor returns $1$, you can proceed to the next test case, or terminate the program if it was the last testcase.

If the interactor returns $0$, it means that your guess is incorrect, and you should to terminate to guarantee a "Wrong answer" verdict.

Note that in every test case the string $p$ is fixed beforehand and will not change during the queries, i.e. the interactor is not adaptive.

After printing any query do not forget to print end of line and flush the output. Otherwise, you might get Idleness limit exceeded. To do this, use:

* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see the documentation for other languages.

Examples

Input

```
1
4

2 1 2

1 2

0

1
```

Output

```? C? CH? CCHO! CCHH
```

Input

```
2
5

0

2 2 3

1
8

1 5

1 5

1 3

2 1 2

1
```

Output

```? O? HHH! CHHHH? COO? COOH? HCCOO? HH! HHHCCOOH
```

Note

Note that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.

Non-adaptive interactor (C++):
#include "testlib.h"
#include <algorithm>
#include <csignal>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

static int queries = 0;
static long long query_limit = 1000000000LL;

void log_queries() {
    tout << "queries=" << queries << "\n";
    tout << "query_limit=" << query_limit << "\n";
}

void quit_with(TResult verdict, const string& msg) {
    log_queries();
    quitf(verdict, "%s", msg.c_str());
}

int main(int argc, char* argv[]) {
    registerInteraction(argc, argv);
    signal(SIGPIPE, SIG_IGN);
    atexit(log_queries);

    const int t = inf.readInt();
    cout << t << "\n" << flush;

    for (int tc = 0; tc < t; tc++) {
        const int n = inf.readInt();
        const string p = inf.readToken();
        if ((int)p.size() != n) {
            quit_with(_fail, "Invalid hidden string length");
        }

        cout << n << "\n" << flush;

        long double energy = 7.0L / 5.0L;

        while (true) {
            string tok;
            if (!(cin >> tok)) {
                quit_with(_pe, "Unexpected EOF");
            }

            if (tok == "?") {
                string s;
                if (!(cin >> s)) {
                    quit_with(_pe, "Invalid query");
                }
                queries++;

                const int len = (int)s.size();
                if (len < 1 || len > n) {
                    cout << "-1\n" << flush;
                    quit_with(_wa, "Invalid query length");
                }

                energy -= 1.0L / (static_cast<long double>(len) * static_cast<long double>(len));
                if (energy < -1e-12L) {
                    cout << "-1\n" << flush;
                    quit_with(_wa, "Energy limit exceeded");
                }

                vector<int> pos;
                for (int i = 0; i + len <= n; i++) {
                    if (p.compare(i, len, s) == 0) {
                        pos.push_back(i + 1);
                    }
                }

                cout << pos.size();
                for (int x : pos) {
                    cout << " " << x;
                }
                cout << "\n" << flush;
                continue;
            }

            if (!tok.empty() && tok[0] == '?' && tok.size() > 1) {
                
                string s = tok.substr(1);
                queries++;

                const int len = (int)s.size();
                if (len < 1 || len > n) {
                    cout << "-1\n" << flush;
                    quit_with(_wa, "Invalid query length");
                }

                energy -= 1.0L / (static_cast<long double>(len) * static_cast<long double>(len));
                if (energy < -1e-12L) {
                    cout << "-1\n" << flush;
                    quit_with(_wa, "Energy limit exceeded");
                }

                vector<int> pos;
                for (int i = 0; i + len <= n; i++) {
                    if (p.compare(i, len, s) == 0) {
                        pos.push_back(i + 1);
                    }
                }

                cout << pos.size();
                for (int x : pos) {
                    cout << " " << x;
                }
                cout << "\n" << flush;
                continue;
            }

            if (tok == "!") {
                string guess;
                if (!(cin >> guess)) {
                    quit_with(_pe, "Missing guess");
                }
                const bool ok = (guess == p);
                cout << (ok ? "1" : "0") << "\n" << flush;
                if (!ok) {
                    quit_with(_wa, "Wrong guess");
                }
                break;
            }

            quit_with(_pe, "Unknown command: " + tok);
        }
    }

    quit_with(_ok, "All tests correct");
}


Adaptive interactor (C++):

Test generator (C++):
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static string gen_string(int n, int mode) {
    static const string ALPH = "CHO";
    string p;
    p.reserve(n);

    if (mode == 0) {
        
        char ch = ALPH[rnd.next(0, 2)];
        p.assign(n, ch);
        return p;
    }
    if (mode == 1) {
        
        for (int i = 0; i < n; i++) p.push_back(ALPH[i % 3]);
        return p;
    }
    if (mode == 2) {
        
        char a = ALPH[rnd.next(0, 2)];
        char b = ALPH[rnd.next(0, 2)];
        while (b == a) b = ALPH[rnd.next(0, 2)];
        for (int i = 0; i < n; i++) p.push_back((i % 2) ? b : a);
        return p;
    }
    if (mode == 3) {
        
        char ch = ALPH[rnd.next(0, 2)];
        p.assign(n, ch);
        int flips = max(1, n / 10);
        for (int i = 0; i < flips; i++) {
            int pos = rnd.next(0, n - 1);
            char other = ALPH[rnd.next(0, 2)];
            while (other == ch) other = ALPH[rnd.next(0, 2)];
            p[pos] = other;
        }
        return p;
    }

    
    for (int i = 0; i < n; i++) p.push_back(ALPH[rnd.next(0, 2)]);
    return p;
}

int main(int argc, char* argv[]) {
    registerGen(argc, argv, 1);

    const long long seed = (argc >= 2) ? atoll(argv[1]) : 1;

    int t = 10;
    if (seed == 1) t = 1;
    else if (seed == 2) t = 2;
    else if (seed <= 5) t = 5;
    else if (seed <= 20) t = 10;
    else t = 20;
    t = max(1, min(500, t));

    cout << t << "\n";
    for (int tc = 0; tc < t; tc++) {
        int n = 50;
        if (seed == 1) n = 4;
        else if (seed == 2) n = 5;
        else if (seed <= 10) n = 10 + (int)seed;
        else n = 50;
        n = max(4, min(50, n));

        int mode = (int)((seed + tc) % 6);
        string p = gen_string(n, mode);

        cout << n << "\n";
        cout << p << "\n";
    }
    return 0;
}