This is an interactive problem.

Given a simple undirected graph with $n$ vertices numbered from $1$ to $n$, your task is to color all the vertices such that for every color $c$, the following conditions hold:

1. The set of vertices with color $c$ is connected;
2. $s_c \leq n_c^2$, where $n_c$ is the number of vertices with color $c$, and $s_c$ is the sum of degrees of vertices with color $c$.

It can be shown that there always exists a way to color all the vertices such that the above conditions hold.

Initially, you are only given the number $n$ of vertices and the degree of each vertex.

In each query, you can choose a vertex $u$. As a response, you will be given the $k$-th edge incident to $u$, if this is the $k$-th query on vertex $u$.

You are allowed to make at most $n$ queries.

An undirected graph is simple if it does not contain multiple edges or self-loops.

The degree of a vertex is the number of edges incident to it.

A set $S$ of vertices is connected if for every two different vertices $u, v \in S$, there is a path, which only passes through vertices in $S$, that connects $u$ and $v$. That is, there is a sequence of edges $(u_1, v_1), (u_2, v_2), \dots, (u_k, v_k)$ with $k \geq 1$ such that

1. $u_1 = u$, $v_k = v$, and $v_i = u_{i+1}$ for every $1 \leq i < k$; and
2. $u_k \in S$ and $v_k \in S$ for every $1 \leq i \leq k$.

Especially, a set containing only one vertex is connected.

Interaction

Each test contains multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 1000$) — the number of test cases. The following lines contain the description and the interactive section of each test case.

For each test case, you begin the interaction by reading an integer $n$ ($1\le n \le 1000$) in the first line, indicating the number of vertices in the graph.

The second line contains $n$ integers $d_1, d_2, \dots, d_n$ ($0 \leq d_i \leq n - 1$), where $d_i$ is the degree of vertex $i$.

To make a query on vertex $u$ ($1 \leq u \leq n$), you should output

* "? $u$"

in a separate line. If this is the $k$-th query on vertex $u$, vertex $e_{u, k}$ will be given in the next separate line, where $\left(u, e_{u, k}\right)$ is the $k$-th edge incident to vertex $u$. In case of $k > d_u$, define $e_{u, k} = -1$. You should make no more than $n$ "?" queries.

To give the answer, you should output

* "! $c_1$ $c_2$ $\dots$ $c_n$"

in a separate line, where $c_i$ ($1 \leq c_i \leq n$) is the color of vertex $i$. After that, your program should continue to the next test case, or terminate if this is the last test case.

It is guaranteed that the graph is a simple undirected graph.

It is guaranteed that the sum of $n$ over all test cases does not exceed $1000$.

In case your query format is invalid, or you have made more than $n$ "?" queries, you will receive Wrong Answer verdict.

After printing a query, do not forget to output end of line and flush the output. Otherwise, you will 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 documentation for other languages.

Example

Input

```
1
5
2 2 2 2 0

2

4

2

4
```

Output

```
? 1

? 1

? 3

? 3

! 1 1 2 2 3
```

Note

In the example, there is only one test case.

In the test case, there are $n = 5$ vertices with vertices $1, 2, 3, 4$ of degree $2$ and vertex $5$ of degree $0$. It is obvious that vertex $5$ is isolated, i.e., it does not connect to any other vertices.

A possible interaction is shown in the sample input and output, where $4$ "?" queries are made on vertex $1$ twice and vertex $3$ twice. According to the responses to these queries, we know that each of vertex $1$ and vertex $3$ connects to two vertices $2$ and $4$.

A possible solution is shown in the sample output, where vertex $1$ and vertex $2$ are colored by $1$, vertex $3$ and vertex $4$ are colored by $2$, and vertex $5$ is colored by $3$. It can be seen that this solution satisfies the required conditions as follows.

* For color $c = 1$, vertex $1$ and vertex $2$ are connected. Moreover, $n_1 = 2$ and $s_1 = d_1 + d_2 = 2 + 2 = 4 \leq n_1^2 = 2^2 = 4$;
* For color $c = 2$, vertex $3$ and vertex $4$ are connected. Moreover, $n_2 = 2$ and $s_2 = d_3 + d_4 = 2 + 2 = 4 \leq n_2^2 = 2^2 = 4$;
* For color $c = 3$, there is only one vertex (vertex $5$) colored by $3$. Moreover, $n_3 = 1$ and $s_3 = d_5 = 0 \leq n_3^2 = 1^2 = 1$.

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static long long queries = 0;
static long long query_limit = 0;
static const long long HARD_CAP = 200000;

static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {

    }
}

template<typename... Args>
void finish(TResult verdict, const char* fmt, Args... args) {
    log_metrics();
    quitf(verdict, fmt, args...);
}

int n;
vector<vector<int>> adj;
vector<int> degree;
vector<int> vertex_query_count;

void solve_test_case() {

    n = inf.readInt(1, 1000, "n");

    int m = inf.readInt(0, n * (n - 1) / 2, "m");

    query_limit += n;

    log_metrics();

    adj.assign(n + 1, vector<int>());
    degree.assign(n + 1, 0);
    for (int i = 0; i < m; i++) {
        int u = inf.readInt(1, n, "u");
        int v = inf.readInt(1, n, "v");
        adj[u].push_back(v);
        adj[v].push_back(u);
        degree[u]++;
        degree[v]++;
    }

    for (int i = 1; i <= n; i++) {
        sort(adj[i].begin(), adj[i].end());
    }

    cout << n << endl;
    for (int i = 1; i <= n; i++) {
        cout << degree[i] << (i == n ? "" : " ");
    }
    cout << endl;

    vertex_query_count.assign(n + 1, 0);

    while (true) {
        if (queries > HARD_CAP) {
            finish(_pe, "Hard query limit exceeded (infinite loop?)");
        }

        string token;
        if (!(cin >> token)) {
            finish(_pe, "Unexpected EOF while waiting for query/answer");
        }

        if (token == "!") {

            vector<int> c(n + 1);
            vector<vector<int>> color_groups(n + 1);

            for (int i = 1; i <= n; i++) {
                string col_str;
                if (!(cin >> col_str)) {
                    finish(_pe, "Unexpected EOF reading color for vertex %d", i);
                }
                try {
                    c[i] = stoi(col_str);
                } catch (...) {
                    finish(_pe, "Invalid color format (not an integer)");
                }

                if (c[i] < 1 || c[i] > n) {
                    finish(_wa, "Color %d for vertex %d is out of range [1, %d]", c[i], i, n);
                }
                color_groups[c[i]].push_back(i);
            }

            for (int k = 1; k <= n; k++) {
                if (color_groups[k].empty()) continue;
                const auto& nodes = color_groups[k];

                if (nodes.size() > 1) {
                    unordered_set<int> node_set(nodes.begin(), nodes.end());
                    int visited_count = 0;
                    queue<int> q;
                    q.push(nodes[0]);
                    unordered_set<int> visited;
                    visited.insert(nodes[0]);

                    while (!q.empty()) {
                        int u = q.front();
                        q.pop();
                        visited_count++;
                        for (int v : adj[u]) {
                            if (node_set.count(v) && !visited.count(v)) {
                                visited.insert(v);
                                q.push(v);
                            }
                        }
                    }
                    if (visited_count != (int)nodes.size()) {
                        finish(_wa, "Vertices with color %d are not connected", k);
                    }
                }

                long long sum_deg = 0;
                for (int u : nodes) {
                    sum_deg += degree[u];
                }
                long long size = nodes.size();
                if (sum_deg > size * size) {
                    finish(_wa, "Color %d: sum of degrees (%lld) exceeds size^2 (%lld)", k, sum_deg, size * size);
                }
            }

            return;

        } else {

            int u = -1;
            if (token == "?") {
                if (!(cin >> u)) {
                    finish(_pe, "Expected vertex index after '?'");
                }
            } else {
                try {
                    u = stoi(token);
                } catch (...) {
                    finish(_pe, "Invalid token '%s': expected '?' or '!' or vertex index", token.c_str());
                }
            }

            if (u < 1 || u > n) {
                finish(_wa, "Query vertex %d out of range [1, %d]", u, n);
            }

            queries++;

            if (queries % 10 == 0) log_metrics();

            vertex_query_count[u]++;
            int k = vertex_query_count[u];

            int neighbor = -1;
            if (k <= degree[u]) {

                neighbor = adj[u][k - 1];
            }
            cout << neighbor << endl;
        }
    }
}

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    int t = inf.readInt(1, 1000, "t");
    cout << t << endl;

    while (t--) {
        solve_test_case();
    }

    finish(_ok, "All test cases passed");
}

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static long long total_queries = 0;
static long long total_limit = 0;
static bool metrics_logged = false;

static void log_metrics() {
    if (metrics_logged) return;
    metrics_logged = true;

    if (tout.is_open()) {
        tout << "queries=" << total_queries << endl;
        tout << "query_limit=" << total_limit << endl;
    }
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

static void on_exit() {
    log_metrics();
}

void solve() {

    int n = inf.readInt();
    int m = inf.readInt();

    vector<vector<int>> adj(n + 1);

    vector<int> deg(n + 1, 0);

    for (int i = 0; i < m; ++i) {
        int u = inf.readInt();
        int v = inf.readInt();

        if (u >= 1 && u <= n && v >= 1 && v <= n) {
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
    }

    for (int i = 1; i <= n; ++i) {
        deg[i] = adj[i].size();
    }

    cout << n << endl;
    for (int i = 1; i <= n; ++i) {
        cout << deg[i] << (i == n ? "" : " ");
    }
    cout << endl;

    total_limit += n;

    int local_queries = 0;
    int limit = n;

    vector<int> asked(n + 1, 0);

    while (true) {
        string type;
        if (!(cin >> type)) {
            finish(_pe, "Unexpected EOF from contestant");
        }

        if (type == "!") {

            vector<int> colors(n + 1);
            for (int i = 1; i <= n; ++i) {
                if (!(cin >> colors[i])) {
                    finish(_pe, "Cannot read colors");
                }
                if (colors[i] < 1 || colors[i] > n) {
                    finish(_wa, "Color index out of range [1, n]");
                }
            }

            map<int, vector<int>> groups;
            for (int i = 1; i <= n; ++i) {
                groups[colors[i]].push_back(i);
            }

            for (auto& entry : groups) {
                int c = entry.first;
                vector<int>& nodes = entry.second;
                if (nodes.empty()) continue;

                set<int> node_set(nodes.begin(), nodes.end());
                queue<int> q;
                q.push(nodes[0]);
                set<int> visited;
                visited.insert(nodes[0]);

                while(!q.empty()) {
                    int u = q.front(); q.pop();
                    for (int v : adj[u]) {

                        if (node_set.count(v) && !visited.count(v)) {
                            visited.insert(v);
                            q.push(v);
                        }
                    }
                }

                if ((int)visited.size() != (int)nodes.size()) {
                    finish(_wa, "Color " + to_string(c) + " is not connected");
                }

                long long sum_deg = 0;
                for (int u : nodes) {
                    sum_deg += deg[u];
                }
                long long nc = nodes.size();
                if (sum_deg > nc * nc) {
                    finish(_wa, "Color " + to_string(c) + " violates degree condition: s_c=" + to_string(sum_deg) + " > n_c^2=" + to_string(nc*nc));
                }
            }

            return;

        } else if (type == "?") {
            int u;
            if (!(cin >> u)) finish(_pe, "Invalid query format");

            total_queries++;
            local_queries++;

            if (local_queries > limit) {
                finish(_wa, "Too many queries");
            }

            if (u < 1 || u > n) {
                finish(_wa, "Invalid vertex index in query");
            }

            int k = asked[u];
            asked[u]++;

            if (k < (int)adj[u].size()) {

                cout << adj[u][k] << endl;
            } else {

                cout << -1 << endl;
            }

        } else {
            finish(_pe, "Invalid query type: " + type);
        }
    }
}

int main(int argc, char** argv) {

    registerInteraction(argc, argv);
    atexit(on_exit);

    int t = inf.readInt();

    cout << t << endl;

    while(t--) {
        solve();
    }

    finish(_ok, "All cases passed");
    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

void output(int n, vector<pair<int, int>> edges) {

    vector<int> p(n);
    iota(p.begin(), p.end(), 1);
    shuffle(p.begin(), p.end());

    vector<pair<int, int>> mapped_edges;
    mapped_edges.reserve(edges.size());
    for (auto e : edges) {
        int u = p[e.first - 1];
        int v = p[e.second - 1];
        if (u > v) swap(u, v);
        mapped_edges.push_back({u, v});
    }

    shuffle(mapped_edges.begin(), mapped_edges.end());

    cout << 1 << endl;
    cout << n << " " << mapped_edges.size() << endl;
    for (auto e : mapped_edges) {
        cout << e.first << " " << e.second << endl;
    }
}

void gen_random(int n, int m) {
    long long max_m = (long long)n * (n - 1) / 2;
    if (m > max_m) m = max_m;

    vector<pair<int, int>> edges;
    if (m > max_m / 2) {

        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                edges.push_back({i, j});
            }
        }
        shuffle(edges.begin(), edges.end());
        edges.resize(m);
    } else {

        set<pair<int, int>> edges_set;
        while ((int)edges_set.size() < m) {
            int u = rnd.next(1, n);
            int v = rnd.next(1, n);
            if (u == v) continue;
            if (u > v) swap(u, v);
            edges_set.insert({u, v});
        }
        for (auto e : edges_set) edges.push_back(e);
    }
    output(n, edges);
}

void gen_tree(int n) {
    if (n == 1) {
        output(n, {});
        return;
    }
    vector<pair<int, int>> edges;

    for (int i = 2; i <= n; ++i) {
        int p = rnd.next(1, i - 1);
        edges.push_back({p, i});
    }
    output(n, edges);
}

void gen_star(int n) {
    if (n == 1) {
        output(n, {});
        return;
    }
    vector<pair<int, int>> edges;
    for (int i = 2; i <= n; ++i) {
        edges.push_back({1, i});
    }
    output(n, edges);
}

void gen_forest(int n, int components) {
    if (n == 1) {
        output(n, {});
        return;
    }
    if (components >= n) {

        output(n, {});
        return;
    }

    set<int> cuts;
    while ((int)cuts.size() < components - 1) {
        cuts.insert(rnd.next(1, n - 1));
    }
    vector<int> sorted_cuts(cuts.begin(), cuts.end());
    vector<int> sizes;
    int prev = 0;
    for (int cut : sorted_cuts) {
        sizes.push_back(cut - prev);
        prev = cut;
    }
    sizes.push_back(n - prev);

    vector<pair<int, int>> edges;
    int offset = 1;
    for (int s : sizes) {

        if (s > 1) {

            for (int i = 1; i < s; ++i) {
                int u = offset + i;
                int p = offset + rnd.next(0, i - 1);
                edges.push_back({p, u});
            }

            int extra = rnd.next(0, min((int)(s * (s - 1) / 2 - (s - 1)), 2 * s));
            for (int k = 0; k < extra; ++k) {
                int u = rnd.next(offset, offset + s - 1);
                int v = rnd.next(offset, offset + s - 1);
                if (u != v) {
                    if (u > v) swap(u, v);
                    edges.push_back({u, v});
                }
            }
        }
        offset += s;
    }

    sort(edges.begin(), edges.end());
    edges.erase(unique(edges.begin(), edges.end()), edges.end());
    output(n, edges);
}

void gen_multi_stars(int n, int k) {
    if (n == 1) {
        output(n, {});
        return;
    }
    vector<pair<int, int>> edges;
    int remaining = n - k;
    if (remaining < 0) remaining = 0;

    int current_node = k + 1;
    for (int i = 1; i <= k; ++i) {
        if (remaining == 0) break;
        int count = (i == k) ? remaining : rnd.next(0, remaining);
        remaining -= count;
        for (int j = 0; j < count; ++j) {
            edges.push_back({i, current_node++});
        }
    }
    output(n, edges);
}

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

    string mode = opt<string>("mode", "non");

    int seed = atoi(argv[1]);

    if (seed == 1) {
        output(1, {});
        return 0;
    }
    if (seed == 2) {
        output(5, {{1,2}, {2,3}, {3,4}, {4,5}});
        return 0;
    }
    if (seed == 3) {
        gen_star(6);
        return 0;
    }
    if (seed == 4) {
        gen_random(5, 10);
        return 0;
    }
    if (seed == 5) {
        output(6, {{1,2}, {2,3}, {1,3}, {4,5}, {5,6}, {4,6}});
        return 0;
    }

    int n;
    if (seed % 10 == 0) n = rnd.next(1, 20);
    else if (seed % 10 == 1) n = rnd.next(900, 1000);
    else n = rnd.next(50, 1000);

    int type = rnd.next(1, 6);

    if (seed > 100) {
        type = rnd.next(1, 10);
        if (type > 6) type = 4;
    }

    switch(type) {
        case 1: {
            long long lim = (long long)n * (n - 1) / 2;
            int m = rnd.next(0, (int)min(lim, (long long)n * 2));
            gen_random(n, m);
            break;
        }
        case 2: {
            long long lim = (long long)n * (n - 1) / 2;
            int low = min(lim, (long long)n * 3);
            int m = rnd.next(low, (int)lim);
            gen_random(n, m);
            break;
        }
        case 3:
            gen_tree(n);
            break;
        case 4:
            gen_forest(n, rnd.next(2, max(2, n / 10)));
            break;
        case 5:
            gen_multi_stars(n, rnd.next(1, max(1, n / 5)));
            break;
        case 6:
            gen_star(n);
            break;
        default:
            gen_random(n, n);
            break;
    }

    return 0;
}


This is an interactive problem.

After completing the last level of the enchanted temple, you received a powerful artifact of the 255th level. Do not rush to celebrate, because this artifact has a powerful rune that can be destroyed with a single spell $s$, which you are going to find.

We define the spell as some non-empty string consisting only of the letters a and b.

At any time, you can cast an arbitrary non-empty spell $t$, and the rune on the artifact will begin to resist. Resistance of the rune is the edit distance between the strings that specify the casted spell $t$ and the rune-destroying spell $s$.

Edit distance of two strings $s$ and $t$ is a value equal to the minimum number of one-character operations of replacing, inserting and deleting characters in $s$ to get $t$. For example, the distance between ababa and aaa is $2$, the distance between aaa and aba is $1$, the distance between bbaba and abb is $3$. The edit distance is $0$ if and only if the strings are equal.

It is also worth considering that the artifact has a resistance limit  — if you cast more than $n + 2$ spells, where $n$ is the length of spell $s$, the rune will be blocked.

Thus, it takes $n + 2$ or fewer spells to destroy the rune that is on your artifact. Keep in mind that the required destructive spell $s$ must also be counted among these $n + 2$ spells.

Note that the length $n$ of the rune-destroying spell $s$ is not known to you in advance. It is only known that its length $n$ does not exceed $300$.

Interaction

Interaction is happening through queries.

Each request consists of a single non-empty string $t$  — the spell you want to cast. The length of string $t$ should not exceed $300$. Each string should consist only of the letters a and b.

In response to the query, you will get resistance runes  — the edit distance between the strings that specify the casted spell $t$ and the secret rune-destroying spell $s$. Remember that $s$ contains only the letters a and b.

After breaking the rune, your program should end immediately. A rune is destroyed when you get a response with resistance $0$. After receiving the value $0$, your program should terminate normally.

In this problem interactor is not adaptive. This means that during any test the rune-destroying spell $s$ does not change.

If your query is invalid, -1 will be returned. After receiving this your program should immediately terminate normally (for example, by calling exit(0)), otherwise, the testing system may issue an arbitrary verdict.

If the number of spells exceeds limit ($n + 2$, where $n$ is the length of the spell $s$, which is unknown to you), you will get the Wrong Answer verdict.

Your solution may receive the verdict Idleness Limit Exceeded if you don't output anything or forget to flush the output buffer.

To flush the output buffer, you need to do the following immediately after printing the query and the line end:

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

Example

Input

```
2

2

1

2

3

0
```

Output

```
aaa

aaab

abba

bba

abaaa

aabba
```

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static long long queries = 0;
static long long query_limit = 0;

static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {

    }
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

static bool isValidSpell(const string& t) {
    if (t.empty() || (int)t.size() > 300) return false;
    for (char c : t) if (c != 'a' && c != 'b') return false;
    return true;
}

struct MyersED {
    int m = 0;
    int blocks = 0;
    uint64_t lastMask = 0;
    vector<uint64_t> peqA, peqB;

    explicit MyersED(const string& pattern) {
        m = (int)pattern.size();
        blocks = (m + 63) / 64;
        lastMask = (m % 64 == 0) ? ~0ULL : ((1ULL << (m % 64)) - 1ULL);
        peqA.assign(blocks, 0);
        peqB.assign(blocks, 0);
        for (int i = 0; i < m; i++) {
            int b = i >> 6;
            int bit = i & 63;
            if (pattern[i] == 'a') peqA[b] |= (1ULL << bit);
            else peqB[b] |= (1ULL << bit);
        }
    }

    int distanceTo(const string& text) const {
        vector<uint64_t> Pv(blocks, ~0ULL), Mv(blocks, 0ULL);
        if (blocks > 0) {
            Pv[blocks - 1] |= ~lastMask;
            Mv[blocks - 1] &= lastMask;
        }

        int score = m;
        const int lastBlock = blocks - 1;
        const uint64_t lastBit = 1ULL << ((m - 1) & 63);

        for (char ch : text) {
            const vector<uint64_t>& Peq = (ch == 'a') ? peqA : peqB;

            uint64_t carryAdd = 0;
            uint64_t carryPh = 0;
            uint64_t carryMh = 0;

            for (int b = 0; b < blocks; b++) {
                uint64_t Eq = Peq[b];
                uint64_t Pv_b = Pv[b];
                uint64_t Mv_b = Mv[b];

                uint64_t Xv = Eq | Mv_b;

                uint64_t temp = Eq & Pv_b;
                unsigned __int128 sum128 = (unsigned __int128)temp + (unsigned __int128)Pv_b + (unsigned __int128)carryAdd;
                uint64_t sum = (uint64_t)sum128;
                carryAdd = (uint64_t)(sum128 >> 64);

                uint64_t Xh = (sum ^ Pv_b) | Eq;
                uint64_t Ph = Mv_b | ~(Xh | Pv_b);
                uint64_t Mh = Pv_b & Xh;

                if (b == lastBlock) {
                    if (Ph & lastBit) score++;
                    else if (Mh & lastBit) score--;
                }

                uint64_t nextCarryPh = (Ph >> 63) & 1ULL;
                uint64_t nextCarryMh = (Mh >> 63) & 1ULL;

                uint64_t PhShift = (Ph << 1) | carryPh;
                if (b == 0) PhShift |= 1ULL;
                uint64_t MhShift = (Mh << 1) | carryMh;

                carryPh = nextCarryPh;
                carryMh = nextCarryMh;

                Pv[b] = MhShift | ~(Xv | PhShift);
                Mv[b] = PhShift & Xv;

                if (b == lastBlock) {
                    Pv[b] |= ~lastMask;
                    Mv[b] &= lastMask;
                }
            }
        }
        return score;
    }
};

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string secret = inf.readToken();
    if (!isValidSpell(secret)) {
        query_limit = 0;
        log_metrics();
        finish(_fail, "Invalid hidden input");
    }

    query_limit = (long long)secret.size() + 2;
    log_metrics();

    const long long hard_cap = max(200000LL, 10LL * query_limit);

    MyersED ed(secret);

    while (true) {
        string t;
        if (!(cin >> t)) {
            finish(_wa, "Contestant terminated without finding the secret");
        }

        if (!isValidSpell(t)) {
            cout << -1 << endl;
            finish(_wa, "Invalid query");
        }

        queries++;
        if (queries > hard_cap) {
            finish(_pe, "Hard cap exceeded");
        }

        int dist = ed.distanceTo(t);
        cout << dist << endl;

        if (dist == 0) {
            finish(_ok, "Solved");
        }
    }
}

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static string thueMorse(int n) {
    string s;
    s.reserve(n);
    for (int i = 0; i < n; i++) {
        int x = i;
        int parity = 0;
        while (x) {
            parity ^= (x & 1);
            x >>= 1;
        }
        s.push_back(parity ? 'b' : 'a');
    }
    return s;
}

static void ensureBothLetters(string& s) {
    bool hasA = false, hasB = false;
    for (char c : s) {
        if (c == 'a') hasA = true;
        if (c == 'b') hasB = true;
    }
    if (!hasA && !s.empty()) s[rnd.next(0, (int)s.size() - 1)] = 'a';
    if (!hasB && !s.empty()) s[rnd.next(0, (int)s.size() - 1)] = 'b';
}

static string genAdversarial(int n, int style) {
    string s;
    s.reserve(n);

    auto randChar = [&]() -> char { return rnd.next(0, 1) ? 'b' : 'a'; };

    if (style == 0) {
        s = thueMorse(n);
        ensureBothLetters(s);
        return s;
    }

    if (style == 1) {
        char cur = randChar();
        int pos = 0;
        while (pos < n) {
            int remaining = n - pos;
            int maxRun = min(remaining, 60);
            int run = rnd.next(1, maxRun);
            for (int i = 0; i < run; i++) s.push_back(cur);
            pos += run;
            cur = (cur == 'a' ? 'b' : 'a');
        }
        ensureBothLetters(s);
        return s;
    }

    if (style == 2) {
        int pos = 0;
        while (pos < n) {
            int remaining = n - pos;
            int kind = rnd.next(0, 2);
            int segMax = min(remaining, 80);
            int len = rnd.next(1, segMax);

            if (kind == 0) {
                char c = randChar();
                for (int i = 0; i < len; i++) s.push_back(c);
            } else if (kind == 1) {
                char start = randChar();
                for (int i = 0; i < len; i++) {
                    s.push_back((i % 2 == 0) ? start : (start == 'a' ? 'b' : 'a'));
                }
            } else {
                for (int i = 0; i < len; i++) s.push_back(randChar());
            }
            pos += len;
        }
        ensureBothLetters(s);
        return s;
    }

    if (style == 3) {
        string half;
        half.reserve((n + 1) / 2);
        for (int i = 0; i < (n + 1) / 2; i++) half.push_back(randChar());
        s = half;
        for (int i = n / 2 - 1; i >= 0; i--) s.push_back(half[i]);

        int flips = max(1, n / 30);
        for (int k = 0; k < flips; k++) {
            int idx = rnd.next(0, n - 1);
            s[idx] = (s[idx] == 'a' ? 'b' : 'a');
        }
        ensureBothLetters(s);
        return s;
    }

    for (int i = 0; i < n; i++) s.push_back(randChar());
    for (int i = 0; i < n; i += 7) {
        if (rnd.next(0, 3) == 0) {
            char c = s[i];
            int r = min(n, i + rnd.next(1, 7));
            for (int j = i; j < r; j++) s[j] = c;
        }
    }
    ensureBothLetters(s);
    return s;
}

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

    string mode = opt<string>("mode", "non");
    ensuref(mode == "non" || mode == "adp", "Unknown mode: %s", mode.c_str());

    int nOpt = opt<int>("n", -1);
    int nmin = opt<int>("nmin", 300);
    int nmax = opt<int>("nmax", 300);
    if (nmin > nmax) swap(nmin, nmax);

    int n;
    if (nOpt != -1) n = nOpt;
    else n = rnd.next(nmin, nmax);

    n = max(1, min(300, n));

    if (mode == "adp") {
        cout << n << "\n";
        return 0;
    }

    int seed = 1;
    if (argc >= 2) {
        seed = atoi(argv[1]);
        if (seed <= 0) seed = 1;
    }

    string s;
    if (nOpt == -1 && seed == 1) {
        s = "a";
    } else if (nOpt == -1 && seed == 2) {
        s = string(300, 'a');
    } else if (nOpt == -1 && seed == 3) {
        s.reserve(300);
        for (int i = 0; i < 300; i++) s.push_back((i % 2 == 0) ? 'a' : 'b');
    } else {
        int style = opt<int>("style", -1);
        if (style < 0) style = rnd.next(0, 4);
        style = max(0, min(4, style));
        s = genAdversarial(n, style);
    }

    ensuref(!s.empty(), "Generated empty string");
    ensuref((int)s.size() >= 1 && (int)s.size() <= 300, "Generated invalid length: %d", (int)s.size());
    for (char c : s) ensuref(c == 'a' || c == 'b', "Invalid character generated");

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


This is an interactive problem. Refer to the Interaction section below for better understanding.

There are $n$ ($2 \le n \le 40$) batteries numbered $1, 2, \ldots, n$. Some of them work while the others don't. Let $a$ be the number of batteries that work. It is guaranteed that $\mathbf{a \geq 2}$.

You are given $n$ but not $a$.

There is a flashlight which can hold two batteries and it only turns on when both batteries work. The batteries have been shuffled and you don't know which ones work and which ones don't. You can choose two batteries and try them in the flashlight.

You want to find a pair of batteries that work. However, you are worried about breaking the flashlight, so you want to limit the amount of trials you attempt.

Therefore, you should find a pair of working batteries using at most $\left \lfloor \frac{n^2}{a} \right \rfloor$ trials.

The interactor is adaptive. This means that whether battery $i$ ($1 \le i \le n$) works is not fixed and may change during the interaction. However, it is guaranteed that there exists a configuration of $a$ working batteries that is consistent with the information that you have received so far.

Input

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 50$). The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \le n \le 40$) — the number of batteries.

It is guaranteed that the sum of $n$ over all test cases does not exceed $200$.

Interaction

The interaction for each test case begins with reading the integer $n$.

To make a query, print a single line with two integers in the following format:

* $\mathbb{u}\,\mathbb{v}$ ($1 \leq u, v \leq n$ and $u \neq v$) — the indices of the batteries you want to test.

After that, read a single integer $x$ — indicating whether the flashlight turned on after inserting those $2$ batteries. If $x=1$, the flashlight turned on. Otherwise, if $x=0$, the flashlight did not turn on.

After finding a pair of batteries that turns the flashlight on, the interaction of the test case is considered successful, and it will terminate. After that, the interaction continues with the next test case.

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.

Example

Input

```
2
3

0

1
10

0

0

1
```

Output

```
1 2

2 3

1 2

1 3

1 4
```

Note

In the first test, there are $3$ batteries. Only batteries $2$ and $3$ work. Therefore, $a=2$ and we have to find a pair of batteries that work in $\lfloor \frac{n^2}{a} \rfloor = \lfloor \frac{3^2}{2} \rfloor = 4$ queries.

The interaction proceeds as follows:

|  |  |  |
| --- | --- | --- |
| Participant | Jury | Explanation |
| — | $3$ | There are $3$ batteries in this test case |
| $1$   $2$ | $0$ | The solution asks whether batteries $1$ and $2$ turn the flashlight on. The jury responds that they don't. |
| $2$   $3$ | $1$ | The solution asks whether batteries $2$ and $3$ turn the flashlight on. The jury responds that they do. A pair of batteries that work is found, so the interaction of the first test case terminates successfully. |

In the second test case, there are $10$ batteries. Only batteries $1$, $4$, $6$ and $9$ work. Therefore, $a=4$ and we have to find a pair of batteries that work in $\lfloor \frac{n^2}{a} \rfloor = \lfloor \frac{10^2}{4} \rfloor = 25$ queries.

The interaction proceeds as follows:

|  |  |  |
| --- | --- | --- |
| Participant | Jury | Explanation |
| — | $10$ | There are $10$ batteries in this test case. |
| $1$   $2$ | $0$ | The solution asks whether batteries $1$ and $2$ turn the flashlight on. The jury responds that they don't. |
| $1$   $3$ | $0$ | The solution asks whether batteries $1$ and $3$ turn the flashlight on. The jury responds that they don't. |
| $1$   $4$ | $1$ | The solution asks whether batteries $1$ and $4$ turn the flashlight on. The jury responds that they do. A pair of batteries that work is found, so the interaction of the first test case terminates successfully. |

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

static long long queries = 0;
static long long query_limit = 0;

static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {
    }
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    int t = inf.readInt(1, 50, "t");
    vector<int> ns(t), as(t);
    vector<vector<int>> working_lists(t);

    long long total_limit = 0;
    for (int tc = 0; tc < t; tc++) {
        int n = inf.readInt(2, 40, "n");
        int a = inf.readInt(2, n, "a");

        vector<int> working(a);
        for (int i = 0; i < a; i++) working[i] = inf.readInt(1, n, "working");
        sort(working.begin(), working.end());
        working.erase(unique(working.begin(), working.end()), working.end());
        if ((int)working.size() != a) finish(_fail, "Hidden working set is not a-size distinct");

        ns[tc] = n;
        as[tc] = a;
        working_lists[tc] = std::move(working);

        total_limit += 1LL * n * n / a;
    }
    query_limit = total_limit;
    log_metrics();

    cout << t << endl;
    cout.flush();

    for (int tc = 0; tc < t; tc++) {
        int n = ns[tc];
        int a = as[tc];
        const vector<int>& working = working_lists[tc];
        vector<char> is_working(n + 1, 0);
        for (int v : working) is_working[v] = 1;

        long long local_limit = 1LL * n * n / a;
        long long local_queries = 0;

        cout << n << endl;
        cout.flush();

        while (true) {
            int u, v;
            if (!(cin >> u >> v)) finish(_wa, "Unexpected EOF (expected query)");

            local_queries++;
            queries++;
            if (queries % 50 == 0) log_metrics();

            if (local_queries > local_limit) {
                cout << -1 << endl;
                cout.flush();
                finish(_wa, "Query limit exceeded");
            }

            if (u < 1 || u > n || v < 1 || v > n || u == v) {
                cout << -1 << endl;
                cout.flush();
                finish(_wa, "Invalid query");
            }

            int resp = (is_working[u] && is_working[v]) ? 1 : 0;
            cout << resp << endl;
            cout.flush();
            if (resp == 1) break;
        }
    }

    finish(_ok, "All test cases passed");
}

#include "testlib.h"

#include <algorithm>
#include <csignal>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

static long long queries = 0;
static long long query_limit = 0;

static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {
    }
}

[[noreturn]] static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

static bool has_clique_at_least(const vector<unsigned long long>& adj, int n, int target) {
    if (target <= 1) return true;
    if (target > n) return false;

    const unsigned long long full = (n == 64) ? ~0ULL : ((1ULL << n) - 1ULL);

    auto popcnt = [](unsigned long long x) -> int { return __builtin_popcountll(x); };

    function<bool(unsigned long long, int)> dfs = [&](unsigned long long cand, int sz) -> bool {
        if (sz >= target) return true;
        if (cand == 0) return false;
        if (sz + popcnt(cand) < target) return false;

        int pivot = -1;
        int best_deg = -1;
        unsigned long long tmp = cand;
        while (tmp) {
            int u = __builtin_ctzll(tmp);
            tmp &= tmp - 1;
            int deg = popcnt(cand & adj[u]);
            if (deg > best_deg) {
                best_deg = deg;
                pivot = u;
            }
        }
        if (pivot < 0) return false;

        unsigned long long to_try = cand & (~adj[pivot]) & full;
        while (to_try) {
            int v = __builtin_ctzll(to_try);
            to_try &= to_try - 1;
            unsigned long long next = cand & adj[v];
            if (dfs(next, sz + 1)) return true;
            cand &= ~(1ULL << v);
            if (sz + popcnt(cand) < target) return false;
            to_try = cand & (~adj[pivot]) & full;
        }
        return false;
    };

    return dfs(full, 0);
}

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

    const int t = inf.readInt(1, 50, "t");
    vector<int> ns(t), as(t);

    long long total_limit = 0;
    for (int tc = 0; tc < t; tc++) {
        const int n = inf.readInt(2, 40, "n");
        const int a = inf.readInt(2, n, "a");
        ns[tc] = n;
        as[tc] = a;
        total_limit += 1LL * n * n / a;
    }
    query_limit = total_limit;
    log_metrics();

    cout << t << endl;
    cout.flush();

    for (int tc = 0; tc < t; tc++) {
        const int n = ns[tc];
        const int a = as[tc];
        const long long local_limit = 1LL * n * n / a;
        long long local_queries = 0;

        vector<unsigned long long> adj(n);
        const unsigned long long full = (n == 64) ? ~0ULL : ((1ULL << n) - 1ULL);
        for (int i = 0; i < n; i++) adj[i] = full & ~(1ULL << i);

        cout << n << endl;
        cout.flush();

        while (true) {
            int u, v;
            if (!(cin >> u >> v)) finish(_wa, "Unexpected EOF (expected query)");

            local_queries++;
            queries++;
            if (queries % 50 == 0) log_metrics();

            if (local_queries > local_limit) {
                cout << -1 << endl;
                cout.flush();
                finish(_wa, "Query limit exceeded");
            }

            if (u < 1 || u > n || v < 1 || v > n || u == v) {
                cout << -1 << endl;
                cout.flush();
                finish(_wa, "Invalid query");
            }

            int uu = u - 1;
            int vv = v - 1;
            if (((adj[uu] >> vv) & 1ULL) == 0ULL) {

                cout << 0 << endl;
                cout.flush();
                continue;
            }

            adj[uu] &= ~(1ULL << vv);
            adj[vv] &= ~(1ULL << uu);

            if (has_clique_at_least(adj, n, a)) {
                cout << 0 << endl;
                cout.flush();
                continue;
            }

            adj[uu] |= (1ULL << vv);
            adj[vv] |= (1ULL << uu);
            cout << 1 << endl;
            cout.flush();
            break;
        }
    }

    finish(_ok, "All test cases passed");
    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

struct TestCase {
    int n;
    int a;
    vector<int> working;
};

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

    string mode = opt<string>("mode", "non");

    const int MAX_SUM_N = 200;
    const int MAX_T = 50;

    vector<TestCase> cases;
    int current_sum_n = 0;

    long long seed = atoll(argv[1]);

    if (seed == 1) {

        vector<int> a_vals = {2, 5, 10, 20, 40};
        for (int a : a_vals) {
            cases.push_back({40, a, {}});
        }
    } else if (seed == 2) {

        while (cases.size() < MAX_T && current_sum_n < MAX_SUM_N) {
            int rem = MAX_SUM_N - current_sum_n;
            if (rem < 2) break;

            int n = rnd.next(2, min(rem, 10));
            int a = rnd.next(2, n);

            cases.push_back({n, a, {}});
            current_sum_n += n;
        }
    } else if (seed == 3) {

        while (cases.size() < MAX_T && current_sum_n < MAX_SUM_N) {
            int rem = MAX_SUM_N - current_sum_n;
            if (rem < 2) break;

            int n = rnd.next(max(2, min(rem, 15)), min(rem, 40));

            int limit_a = max(2, (int)sqrt(n) + 2);
            int a = rnd.next(2, min(n, limit_a));

            cases.push_back({n, a, {}});
            current_sum_n += n;
        }
    } else {

        while (cases.size() < MAX_T && current_sum_n < MAX_SUM_N) {
            int rem = MAX_SUM_N - current_sum_n;
            if (rem < 2) break;

            int n_max = min(rem, 40);
            int n = rnd.next(2, n_max);

            if (rnd.next(2) && n_max > 12) {
                n = rnd.next(12, n_max);
            }

            int a = rnd.next(2, n);
            int type = rnd.next(20);
            if (type == 0) a = 2;
            else if (type == 1) a = n;
            else if (type == 2) a = max(2, n/2);

            cases.push_back({n, a, {}});
            current_sum_n += n;
        }
    }

    if (mode == "non") {
        for (auto &c : cases) {
            vector<int> p = rnd.perm(c.n, 1);
            c.working.clear();
            for (int i = 0; i < c.a; ++i) {
                c.working.push_back(p[i]);
            }
            sort(c.working.begin(), c.working.end());
        }
    }

    cout << cases.size() << endl;
    for (const auto &c : cases) {
        if (mode == "non") {
            cout << c.n << " " << c.a << endl;
            for (int i = 0; i < c.a; ++i) {
                cout << c.working[i] << (i == c.a - 1 ? "" : " ");
            }
            cout << endl;
        } else {

            cout << c.n << " " << c.a << endl;
        }
    }

    return 0;
}


Mark is administering an online exam consisting of $n$ true-false questions. However, he has lost all answer keys. He needs a way to retrieve the answers before his client gets infuriated.

Fortunately, he has access to the grading system. Thus, for each query, you can input the answers to all $n$ questions, and the grading system will output how many of them are correct.

He doesn't have much time, so he can use the grading system at most $675$ times. Help Mark determine the answer keys.

Note that answer keys are fixed in advance and will not change depending on your queries.

Input

The first line of the input consists of an integer $n$ ($1\leq n\leq 1000$) — the number of questions.

Interaction

After reading $n$, you can start making queries to the grading system. For each query, print a line containing a string $s$ of length $n$ consisting of only letters 'T' and 'F'.

* $s_i = $'T' means that you answer the $i$-question true.
* $s_i = $'F' means that you answer the $i$-question false.

After a successful query, you should read an integer $k$ ($0\leq k\leq n$) — the number of correct answers. If you read $n$, then you found the answers, and your program should not make any more queries.

If your program reads $k = -1$ instead of the number of correct answers, it means that you either made an invalid query or exceeded the query limits. Exit immediately after receiving $-1$, and you will see Wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

After printing a query do not forget to output end of line and flush the output. Otherwise, you will 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 documentation for other languages.

Examples

Input

```
3

1

3
```

Output

```
FTT

TTF
```

Input

```
4

0

3

4
```

Output

```
FTFF

TTTT

TFTT
```

Note

The empty lines in the example are just for you to better understand the interaction process. You're not required to print them.

In the first example, there are $3$ questions, and the answer to each question is 'true', 'true', and 'false', respectively.

* The first query, guessing the answers to be 'false', 'true', and 'true', respectively, guesses only one question — the $2$-nd question — correctly.
* Then, in the second query, the program correctly guesses the answer key. The interaction ends here.

In the second example, there are $4$ questions, and the answer to each question is 'true', 'false', 'true', and 'true', respectively.

* The first query guessed none of the questions correctly, resulting in the answer $0$.
* The second query guessed the $1$-st, $3$-rd, and $4$-th question correctly, resulting in the answer $3$.
* In the third query, the program correctly guesses the answer key. Then, the interaction ends.

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

static long long queries = 0;
static long long query_limit = 675;

static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {

    }
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    int n = inf.readInt();
    string s = inf.readToken();

    if (s.length() != (size_t)n) {
        quitf(_fail, "Generator error: string length %d does not match n=%d", (int)s.length(), n);
    }

    query_limit = 675;

    cout << n << endl;

    while (true) {
        string token;

        if (!(cin >> token)) {
            finish(_wa, "Unexpected EOF (no answer found)");
        }

        string guess;
        bool is_final_answer = false;

        if (token == "!") {
            is_final_answer = true;
            if (!(cin >> guess)) {
                finish(_wa, "Expected string after '!'");
            }
        } else if (token == "?") {
            if (!(cin >> guess)) {
                finish(_wa, "Expected string after '?'");
            }
        } else {

            guess = token;
        }

        if (guess.length() != (size_t)n) {

            if (!is_final_answer) cout << -1 << endl;
            finish(_wa, format("Invalid string length: expected %d, got %d", n, (int)guess.length()));
        }

        bool valid_chars = true;
        for (char c : guess) {
            if (c != 'T' && c != 'F') {
                valid_chars = false;
                break;
            }
        }
        if (!valid_chars) {
            if (!is_final_answer) cout << -1 << endl;
            finish(_wa, "Invalid characters in guess (must be 'T' or 'F')");
        }

        int correct_count = 0;
        for (int i = 0; i < n; i++) {
            if (guess[i] == s[i]) {
                correct_count++;
            }
        }

        if (is_final_answer) {

            if (correct_count == n) {
                finish(_ok, "Correct answer provided via '!'");
            } else {
                finish(_wa, format("Wrong answer provided via '!': %d/%d matches", correct_count, n));
            }
        } else {

            if (queries >= query_limit) {
                cout << -1 << endl;
                finish(_wa, format("Query limit exceeded (%lld queries)", queries + 1));
            }

            queries++;
            cout << correct_count << endl;

            log_metrics();

            if (correct_count == n) {
                finish(_ok, format("Correct answer found via query in %lld queries", queries));
            }
        }
    }

    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

static long long queries = 0;

static long long query_limit = 675;

static const long long HARD_CAP = 200000;

static int n = 0;
static vector<int> hidden;

void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {

    }
}

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

struct Rng {
    unsigned long long state;
    Rng(unsigned long long seed) : state(seed) {}
    unsigned long long next() {
        state = state * 6364136223846793005ULL + 1442695040888963407ULL;
        return state;
    }
    int next_bit() {
        return (next() >> 32) & 1;
    }
} rng_gen(17052022ULL);

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

    registerInteraction(argc, argv);
    atexit(log_metrics);

    n = inf.readInt();
    string token = inf.readToken();

    log_metrics();

    if (token == "ADAPTIVE") {

        hidden.resize(n);
        for (int i = 0; i < n; ++i) {
            hidden[i] = rng_gen.next_bit();
        }
    } else {

        if ((int)token.size() != n) {
            finish(_fail, format("Generator string length %d does not match n=%d", (int)token.size(), n));
        }
        hidden.resize(n);
        for (int i = 0; i < n; ++i) {
            if (token[i] == 'T') hidden[i] = 1;
            else if (token[i] == 'F') hidden[i] = 0;
            else finish(_fail, "Invalid character in generator string");
        }
    }

    cout << n << endl;

    while (true) {
        string s;

        if (!(cin >> s)) {

            finish(_wa, "Unexpected EOF: solution terminated without finding the answer");
        }

        queries++;
        log_metrics();

        if (queries > HARD_CAP) {
            finish(_pe, "Hard query limit exceeded (infinite loop protection)");
        }

        if ((int)s.size() != n) {
            finish(_wa, format("Invalid query length: expected %d, got %d", n, (int)s.size()));
        }

        int matches = 0;
        for (int i = 0; i < n; ++i) {
            int val = -1;
            if (s[i] == 'T') val = 1;
            else if (s[i] == 'F') val = 0;
            else {
                finish(_wa, "Invalid character in query string (expected 'T' or 'F')");
            }

            if (val == hidden[i]) {
                matches++;
            }
        }

        cout << matches << endl;

        if (matches == n) {
            finish(_ok, format("Correct! Solved in %lld queries.", queries));
        }

    }

    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

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

    registerGen(argc, argv, 1);

    string mode = opt<string>("mode", "non");

    int n = opt<int>("n", -1);

    string seed_str = (argc > 1 ? string(argv[1]) : "");

    if (n == -1) {
        if (seed_str == "1") {
            n = 1;
        } else if (seed_str == "2" || seed_str == "3" || seed_str == "4") {
            n = 1000;
        } else {

            if (rnd.next(4) == 0) n = rnd.next(1, 1000);
            else n = 1000;
        }
    }

    cout << n << endl;

    if (mode == "adp") {

        cout << "ADAPTIVE" << endl;
    } else {

        string s;
        s.reserve(n);

        if (seed_str == "1" && n == 1) {
            s = "T";
        } else if (seed_str == "2" && n == 1000) {
            s = string(n, 'T');
        } else if (seed_str == "3" && n == 1000) {
            s = string(n, 'F');
        } else if (seed_str == "4" && n == 1000) {

            for (int i = 0; i < n; ++i) s += (i % 2 == 0 ? 'T' : 'F');
        } else {

            int strategy = rnd.next(100);

            if (strategy < 5) {

                s = string(n, 'T');
            } else if (strategy < 10) {

                s = string(n, 'F');
            } else if (strategy < 20) {

                for (int i = 0; i < n; ++i) s += (i % 2 == 0 ? 'T' : 'F');
            } else if (strategy < 60) {

                for (int i = 0; i < n; ++i) s += (rnd.next(2) ? 'T' : 'F');
            } else if (strategy < 80) {

                for (int i = 0; i < n; ++i) s += (rnd.next(10) > 0 ? 'T' : 'F');
            } else {

                int block_size = rnd.next(2, max(3, n / 10));
                char current = (rnd.next(2) ? 'T' : 'F');
                for (int i = 0; i < n; ++i) {
                    if (i > 0 && i % block_size == 0) {
                        current = (current == 'T' ? 'F' : 'T');
                    }
                    s += current;
                }
            }
        }
        cout << s << endl;
    }

    return 0;
}


Ivan and Petr like to play with cacti — special graphs where each edge belongs to at most one simple cycle, and the graph is connected. Multiple edges between pairs of vertices and loops are allowed.

They invent the following game:

* Petr secretly builds a cactus with $n$ vertices and $m$ edges. The edges are labeled from $1$ to $m$.
* Petr only tells Ivan the number $m$.
* Ivan is then allowed to ask questions of the following form:
  + He chooses a subset $S$ of edge labels (see below about limitations on the subset), and asks: "If we only keep the edges whose labels are in $S$ (and all $n$ vertices), is the resulting graph connected?"
  + Petr must answer either "yes" or "no".

After asking at most $8m$ questions, Ivan must determine, for every edge:

1. whether this edge lies on some cycle in the cactus;
2. if it does, what is the length of that simple cycle.

In this problem, each loop is considered a simple cycle of length $1$ and two edges between the same pair of vertices form a simple cycle of length $2$.

However, Ivan is still very young and only knows numbers up to $14$. So:

* if an edge lies on a simple cycle of length at most $14$, he must output that exact length;
* if an edge lies on a simple cycle of length greater than $14$, he must say that this edge lies on a big cycle.

Also, to avoid having to list a lot of edges each time, Ivan always asks about an edge set obtained from the set used in one of the previous queries, or from the set of all edges, by removing exactly one edge.

Can you design a strategy that allows Ivan to complete this task?

Input

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 $m$ ($1 \le m \le 10^4$) — the number of edges in the cactus.

It is guaranteed that the sum of $m$ over all test cases does not exceed $10^4$.

Interaction

To ask a query, output a line in the following format (without the quotes):

* "? $p$ $e$" ($0 \le p \le q$; $1 \le e \le m$), where $p$ is the number of a previous query or zero (queries are numbered from 1 in the order they are asked), $q$ is the number of queries made before the current one, $e$ is the label an edge.

The query denotes a graph consisting of the edges used in the query number $p$ (or all edges if $p = 0$), with edge $e$ removed. The interactor checks whether this graph is connected when considering all original vertices and returns a single integer:

* $1$ if the graph denoted by the query is connected;
* $0$ if the graph denoted by the query is not connected;
* $-1$ if you have exceeded $8m$ allowed queries or edge $e$ was already removed from the set of edges used in query $p$. In this case you should terminate your program to receive a Wrong Answer verdict.

When you have found the answer, output a single line in the following format:

* "! $e_1$ $e_2$ $\dots$ $e_m$" ($-1 \le e_i \le 14$ for all $i$),

where:

* if $e_i$ is positive, then edge number $i$ belongs to a simple cycle of length exactly $e_i$,
* if $e_i = 0$, then edge number $i$ belongs to a big cycle (simple cycle of length greater than $14$),
* if $e_i = -1$, then edge number $i$ does not belong to any cycle.

The interactor returns a single integer:

* $1$ if your answer is correct. Proceed to the next test case or terminate your program if this was the last case.
* $-1$ if your answer is incorrect. In this case you should terminate your program to receive a Wrong Answer verdict.

The interactor is not adaptive, meaning that the graph is fixed before you ask any queries.

Example

Input

```
1
7

0

1

1

1
```

Output

```
? 0 1

? 0 3

? 2 4

! -1 3 1 3 2 3 2
```

Note

In the example interaction, the input and output contain empty lines to align interactor responses with queries. These empty lines do not appear in the actual input and output.

In this example, the graph has $5$ vertices and $7$ edges; edges $1$ through $7$, in this order, are $(1, 2)$, $(2, 3)$, $(3, 3)$, $(3, 4)$, $(4, 5)$, $(2, 4)$, $(4, 5)$.

 ![](https://espresso.codeforces.com/8a8b0f0f4dbcd28c3bb58009be11598464b67f35.png)

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static long long queries = 0;
static long long query_limit = 0;

static void log_metrics() {
    try {
        tout << "queries=" << queries << '\n';
        tout << "query_limit=" << query_limit << '\n';
        tout.flush();
    } catch (...) {

    }
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

struct PST {
    struct Node {
        int l = 0, r = 0;
        int mx = 0;
    };
    vector<Node> tr;

    void reset(size_t reserveNodes) {
        tr.clear();
        tr.reserve(reserveNodes);
        tr.push_back(Node{});
    }

    int mx(int v) const { return v == 0 ? 0 : tr[v].mx; }

    int addPoint(int v, int tl, int trr, int pos, int delta) {
        int nv = (int)tr.size();
        tr.push_back(v == 0 ? Node{} : tr[v]);
        if (tl == trr) {
            tr[nv].mx = (v == 0 ? 0 : tr[v].mx) + delta;
            return nv;
        }
        int tm = (tl + trr) >> 1;
        if (pos <= tm) tr[nv].l = addPoint(v == 0 ? 0 : tr[v].l, tl, tm, pos, delta);
        else tr[nv].r = addPoint(v == 0 ? 0 : tr[v].r, tm + 1, trr, pos, delta);
        tr[nv].mx = max(mx(tr[nv].l), mx(tr[nv].r));
        return nv;
    }

    int getPoint(int v, int tl, int trr, int pos) const {
        if (v == 0) return 0;
        if (tl == trr) return tr[v].mx;
        int tm = (tl + trr) >> 1;
        if (pos <= tm) return getPoint(tr[v].l, tl, tm, pos);
        return getPoint(tr[v].r, tm + 1, trr, pos);
    }
};

struct CaseData {
    int n = 0, m = 0;
    vector<int> u, v;
    vector<char> isLoop;
    vector<char> isBridge;
    vector<int> cycleOfEdge;
    vector<int> cycleLen;
    vector<int> expected;
    int numCycles = 0;
};

static CaseData readAndPrecomputeOneCase() {
    CaseData cd;
    cd.n = inf.readInt(1, 20000, "n");
    cd.m = inf.readInt(1, 10000, "m");
    cd.u.assign(cd.m + 1, 0);
    cd.v.assign(cd.m + 1, 0);
    cd.isLoop.assign(cd.m + 1, 0);
    cd.isBridge.assign(cd.m + 1, 0);
    cd.cycleOfEdge.assign(cd.m + 1, 0);

    for (int i = 1; i <= cd.m; i++) {
        cd.u[i] = inf.readInt(1, cd.n, "u");
        cd.v[i] = inf.readInt(1, cd.n, "v");
        cd.isLoop[i] = (cd.u[i] == cd.v[i]);
    }

    vector<vector<pair<int,int>>> adj(cd.n + 1);
    adj.assign(cd.n + 1, {});
    for (int i = 1; i <= cd.m; i++) {
        if (cd.isLoop[i]) continue;
        int a = cd.u[i], b = cd.v[i];
        adj[a].push_back({b, i});
        adj[b].push_back({a, i});
    }

    cd.cycleLen.assign(1, 0);
    cd.numCycles = 0;
    for (int i = 1; i <= cd.m; i++) {
        if (cd.isLoop[i]) {
            cd.numCycles++;
            cd.cycleLen.push_back(1);
            cd.cycleOfEdge[i] = cd.numCycles;
        }
    }

    vector<int> tin(cd.n + 1, 0), low(cd.n + 1, 0), parent(cd.n + 1, 0), parentEdge(cd.n + 1, 0);
    int timer = 0;

    struct Frame {
        int u, p, pe, it;
    };

    auto assignCycleFromBackEdge = [&](int from, int toAncestor, int backEid) {
        vector<int> edges;
        edges.push_back(backEid);
        int cur = from;
        while (cur != toAncestor) {
            int pe = parentEdge[cur];
            if (pe == 0) {
                finish(_fail, "Internal error: back-edge path escaped to root (invalid cactus input?)");
            }
            edges.push_back(pe);
            cur = parent[cur];
        }
        cd.numCycles++;
        int cid = cd.numCycles;
        cd.cycleLen.push_back((int)edges.size());
        for (int eid : edges) {
            if (cd.cycleOfEdge[eid] != 0) {
                finish(_fail, "Invalid cactus: edge belongs to multiple cycles");
            }
            cd.cycleOfEdge[eid] = cid;
        }
    };

    for (int start = 1; start <= cd.n; start++) {
        if (tin[start] != 0) continue;

        vector<Frame> st;
        st.push_back({start, 0, 0, 0});
        parent[start] = 0;
        parentEdge[start] = 0;
        tin[start] = low[start] = ++timer;

        while (!st.empty()) {
            Frame &f = st.back();
            if (f.it >= (int)adj[f.u].size()) {
                int u = f.u;
                int p = f.p;
                int pe = f.pe;
                st.pop_back();
                if (p != 0) {
                    low[p] = min(low[p], low[u]);
                    if (low[u] > tin[p]) {
                        cd.isBridge[pe] = 1;
                    }
                }
                continue;
            }

            auto [to, eid] = adj[f.u][f.it++];
            if (eid == f.pe) continue;

            if (tin[to] == 0) {
                parent[to] = f.u;
                parentEdge[to] = eid;
                tin[to] = low[to] = ++timer;
                st.push_back({to, f.u, eid, 0});
            } else {
                low[f.u] = min(low[f.u], tin[to]);
                if (tin[to] < tin[f.u]) {
                    assignCycleFromBackEdge(f.u, to, eid);
                }
            }
        }
    }

    cd.expected.assign(cd.m + 1, -1);
    for (int i = 1; i <= cd.m; i++) {
        if (cd.isLoop[i]) {
            cd.expected[i] = 1;
            continue;
        }
        if (cd.isBridge[i]) {
            cd.expected[i] = -1;
            continue;
        }
        int cid = cd.cycleOfEdge[i];
        if (cid <= 0 || cid > cd.numCycles) {
            finish(_fail, "Invalid cactus: non-bridge edge without a cycle id");
        }
        int len = cd.cycleLen[cid];
        cd.expected[i] = (len <= 14 ? len : 0);
    }

    return cd;
}

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = inf.readInt(1, 100, "t");
    vector<CaseData> cases;
    cases.reserve(t);

    long long sumLimit = 0;
    for (int i = 0; i < t; i++) {
        CaseData cd = readAndPrecomputeOneCase();
        sumLimit += 8LL * cd.m;
        cases.push_back(std::move(cd));
    }

    query_limit = sumLimit;
    log_metrics();

    long long hard_cap = max(200000LL, 10LL * query_limit);

    cout << t << '\n';
    cout.flush();

    for (int tc = 0; tc < t; tc++) {
        const CaseData& cd = cases[tc];
        int m = cd.m;

        cout << m << '\n';
        cout.flush();

        struct QState {
            int rootRemoved = 0;
            int rootCycle = 0;
            int removedBridges = 0;
        };

        vector<QState> qs;
        qs.reserve((size_t)min<long long>(hard_cap, 8LL * m + 5));
        qs.push_back(QState{});

        PST pstRemoved, pstCycle;
        size_t reserveNodes = (size_t)(min<long long>(hard_cap, 8LL * m + 5) + 5) * 20;
        pstRemoved.reset(reserveNodes);
        pstCycle.reset(reserveNodes);

        int q = 0;
        while (true) {
            string cmd;
            if (!(cin >> cmd)) {
                finish(_pe, "Unexpected EOF from contestant");
            }

            if (cmd == "?") {
                long long pLL, eLL;
                if (!(cin >> pLL >> eLL)) {
                    finish(_pe, "Malformed query line");
                }

                queries++;
                if (queries > hard_cap) {
                    finish(_pe, "Hard cap exceeded");
                }

                if (pLL < 0 || pLL > q) {
                    cout << -1 << '\n';
                    cout.flush();
                    finish(_pe, "Query refers to invalid previous query index");
                }
                if (eLL < 1 || eLL > m) {
                    cout << -1 << '\n';
                    cout.flush();
                    finish(_pe, "Query edge index out of range");
                }

                int p = (int)pLL;
                int e = (int)eLL;

                int baseRemoved = qs[p].rootRemoved;
                int baseCycle = qs[p].rootCycle;
                int baseBridges = qs[p].removedBridges;

                if (p != 0) {
                    int already = pstRemoved.getPoint(baseRemoved, 1, m, e);
                    if (already != 0) {
                        cout << -1 << '\n';
                        cout.flush();
                        finish(_pe, "Edge already removed from referenced set");
                    }
                }

                QState cur;
                cur.removedBridges = baseBridges + (cd.isBridge[e] ? 1 : 0);

                cur.rootRemoved = pstRemoved.addPoint(baseRemoved, 1, m, e, 1);

                cur.rootCycle = baseCycle;
                int cid = cd.cycleOfEdge[e];
                if (cid != 0) {
                    cur.rootCycle = pstCycle.addPoint(baseCycle, 1, cd.numCycles, cid, 1);
                }

                qs.push_back(cur);
                q++;

                int cycleMax = (cur.rootCycle == 0 ? 0 : pstCycle.tr[cur.rootCycle].mx);
                int connected = (cur.removedBridges == 0 && cycleMax <= 1) ? 1 : 0;

                cout << connected << '\n';
                cout.flush();
            } else if (cmd == "!") {
                vector<int> ans(m + 1, 0);
                for (int i = 1; i <= m; i++) {
                    long long x;
                    if (!(cin >> x)) {
                        finish(_pe, "Malformed answer: not enough integers");
                    }
                    if (x < -1 || x > 14) {
                        cout << -1 << '\n';
                        cout.flush();
                        finish(_pe, "Answer value out of allowed range");
                    }
                    ans[i] = (int)x;
                }

                bool ok = true;
                for (int i = 1; i <= m; i++) {
                    if (ans[i] != cd.expected[i]) {
                        ok = false;
                        break;
                    }
                }

                if (!ok) {
                    cout << -1 << '\n';
                    cout.flush();
                    finish(_wa, "Wrong final answer");
                }

                cout << 1 << '\n';
                cout.flush();
                break;
            } else {
                finish(_pe, "Unknown command token");
            }
        }
    }

    finish(_ok, "OK");
    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

struct Edge {
    int u, v;
};

struct CactusBuilder {
    int n = 1;
    vector<Edge> edges;

    int newVertex() { return ++n; }

    void addEdge(int u, int v) { edges.push_back({u, v}); }

    int addBridge(int from) {
        int to = newVertex();
        addEdge(from, to);
        return to;
    }

    void addLoop(int v) { addEdge(v, v); }

    void addTwoCycle(int v) {
        int to = newVertex();
        addEdge(v, to);
        addEdge(v, to);
    }

    void addCycle(int attach, int len) {
        if (len <= 0) return;
        if (len == 1) {
            addLoop(attach);
            return;
        }
        if (len == 2) {
            addTwoCycle(attach);
            return;
        }
        int first = newVertex();
        addEdge(attach, first);
        int prev = first;
        for (int i = 0; i < len - 2; i++) {
            int nxt = newVertex();
            addEdge(prev, nxt);
            prev = nxt;
        }
        addEdge(prev, attach);
    }
};

static void appendSmallRemainder(vector<int>& parts, int r) {

    if (r <= 0) return;
    if (r % 3 == 0) {
        parts.insert(parts.end(), r / 3, 3);
    } else if (r % 3 == 1) {
        if (r >= 4) {
            parts.push_back(2);
            parts.push_back(2);
            parts.insert(parts.end(), (r - 4) / 3, 3);
        } else {
            parts.push_back(1);
        }
    } else {
        parts.push_back(2);
        parts.insert(parts.end(), (r - 2) / 3, 3);
    }
}

static vector<int> makePartsMostly1415(int totalEdges) {
    vector<int> parts;
    int r = totalEdges;

    while (r >= 29) {
        if (rnd.next(0, 1) == 0) {
            parts.push_back(15);
            parts.push_back(14);
        } else {
            parts.push_back(14);
            parts.push_back(15);
        }
        r -= 29;
    }
    if (r >= 15) {
        parts.push_back(15);
        r -= 15;
    }
    if (r >= 14) {
        parts.push_back(14);
        r -= 14;
    }
    appendSmallRemainder(parts, r);

    int sum = 0;
    for (int x : parts) sum += x;
    ensure(sum == totalEdges);
    return parts;
}

static void buildCornerSeed1(CactusBuilder& b, int m) {

    if (m <= 0) m = 1;
    if (m == 1) {
        b.addLoop(1);
        return;
    }

    int cur = 1;
    for (int i = 0; i < m - 1; i++) cur = b.addBridge(cur);
    b.addLoop(1);
}

static void buildCornerSeed2(CactusBuilder& b, int m) {

    if (m < 8) {
        int cur = 1;
        for (int i = 0; i < max(0, m - 1); i++) cur = b.addBridge(cur);
        if ((int)b.edges.size() < m) b.addLoop(1);
        while ((int)b.edges.size() < m) b.addLoop(1);
        return;
    }

    int used = 0;

    int cur = 1;
    vector<int> spine;
    spine.push_back(1);

    int spineLen = min(5, m - 7);
    for (int i = 0; i < spineLen; i++) {
        cur = b.addBridge(cur);
        spine.push_back(cur);
        used++;
    }

    auto addBlock = [&](int attach, int len) {
        b.addCycle(attach, len);
        used += len;
    };

    addBlock(spine[min(2, (int)spine.size() - 1)], 1);
    addBlock(spine[min(3, (int)spine.size() - 1)], 2);
    addBlock(spine[min(4, (int)spine.size() - 1)], 3);
    addBlock(spine.back(), 14);
    addBlock(spine[min(1, (int)spine.size() - 1)], 15);

    int remaining = m - used;
    if (remaining < 0) {

        b = CactusBuilder();
        buildCornerSeed1(b, m);
        return;
    }

    while (remaining >= 15) {
        addBlock(1, 15);
        remaining -= 15;
    }
    while (remaining >= 14) {
        addBlock(1, 14);
        remaining -= 14;
    }
    vector<int> tail;
    appendSmallRemainder(tail, remaining);
    for (int len : tail) addBlock(1, len);

    ensure((int)b.edges.size() == m);
}

static void buildHard(CactusBuilder& b, int m, int biasToRootPct) {
    if (m <= 0) m = 1;
    if (m == 1) {
        b.addLoop(1);
        return;
    }

    int spineLen = min(300, max(1, m / 60));
    spineLen = min(spineLen, m - 1);
    vector<int> spine;
    spine.reserve(spineLen + 1);

    int cur = 1;
    spine.push_back(cur);
    for (int i = 0; i < spineLen; i++) {
        cur = b.addBridge(cur);
        spine.push_back(cur);
    }

    int remaining = m - spineLen;
    if (remaining == 0) {
        ensure((int)b.edges.size() == m);
        return;
    }

    vector<int> parts = makePartsMostly1415(remaining);

    for (int len : parts) {
        int attach;
        if (rnd.next(0, 99) < biasToRootPct) {
            attach = 1;
        } else {
            attach = spine[rnd.next(0, (int)spine.size() - 1)];
        }
        b.addCycle(attach, len);
    }

    ensure((int)b.edges.size() == m);
}

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

    string mode = opt<string>("mode", "non");
    int mOpt = opt<int>("m", -1);

    long long seedVal = 0;
    if (argc >= 2) {

        seedVal = atoll(argv[1]);
    }

    int m;
    if (mOpt != -1) {
        m = mOpt;
    } else if (seedVal == 1) {
        m = 1;
    } else if (seedVal == 2) {
        m = 60;
    } else if (seedVal == 3) {
        m = 10000;
    } else {
        m = rnd.next(9000, 10000);
    }
    m = max(1, min(10000, m));

    if (mode == "adp") {

        cout << 1 << "\n";
        cout << m << "\n";
        return 0;
    }

    if (mode != "non") mode = "non";

    CactusBuilder b;
    if (seedVal == 1) {
        buildCornerSeed1(b, m);
    } else if (seedVal == 2) {
        buildCornerSeed2(b, m);
    } else if (seedVal == 3) {
        buildHard(b, m, 85);
    } else {
        int bias = 70 + rnd.next(0, 20);
        buildHard(b, m, bias);
    }

    ensure((int)b.edges.size() == m);
    cout << 1 << "\n";
    cout << b.n << " " << m << "\n";
    for (const auto& e : b.edges) {
        cout << e.u << " " << e.v << "\n";
    }
    return 0;
}


This is an interactive problem!

Timofey is writing a competition called Capture the Flag (or CTF for short). He has one task left, which involves hacking a security system. The entire system is based on polynomial hashes$^{\text{∗}}$.

Timofey can input a string consisting of lowercase Latin letters into the system, and the system will return its polynomial hash. To hack the system, Timofey needs to find the polynomial hash parameters ($p$ and $m$) that the system uses.

Timofey doesn't have much time left, so he will only be able to make $3$ queries. Help him solve the task.

$^{\text{∗}}$ The polynomial hash of a string $s$, consisting of lowercase Latin letters of length $n$, based on $p$ and modulo $m$ is $(\mathrm{ord}(s_1) \cdot p ^ 0 + \mathrm{ord}(s_2) \cdot p ^ 1 + \mathrm{ord}(s_3) \cdot p ^ 2 + \ldots + \mathrm{ord}(s_n) \cdot p ^ {n - 1}) \bmod m$. Where $s_i$ denotes the $i$-th character of the string $s$, $\mathrm{ord}(\mathrm{chr})$ denotes the ordinal number of the character $\mathrm{chr}$ in the English alphabet, and $x \bmod m$ is the remainder of $x$ when divided by $m$.

Input

Each test consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 10^3$) — the number of test cases.

It is guaranteed that the $p$ and $m$ used by the system satisfy the conditions: $26 < p \leq 50$ and $p + 1 < m \leq 2 \cdot 10^9$.

Interaction

To make a query to the system, output ? $s$, where $s$ is a string of no more than $50$ characters in length, the hash of which you want to know. In response to this query, you will receive the polynomial hash of the string $s$.

To output the answer, output ! $p$ $m$, where $p$ is the base of the hash, and $m$ is the modulus. After that, immediately proceed to the next test case.

You have to make not more than $3$ queries ?, otherwise you will get verdict Wrong Answer.

After outputting a query, do not forget to output a newline and flush the output buffer. Otherwise, you will receive the verdict Idleness limit exceeded. To flush the buffer, 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.

Example

Input

```
1

32

28
```

Output

```
? aa

? yb

! 31 59
```

Note

Answer for the first query is $(ord(a) \cdot 31^0 + ord(a) \cdot 31^1) \mod 59 = (1 + 1 \cdot 31) \mod 59 = 32$.

Answer for the second query is $(ord(y) \cdot 31^0 + ord(b) \cdot 31^1) \mod 59 = (25 + 2 \cdot 31) \mod 59 = 28$.

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

static long long queries = 0;
static long long query_limit = 0;

static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {

    }
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

int main(int argc, char** argv) {

    registerInteraction(argc, argv);
    atexit(log_metrics);

    int t = inf.readInt();

    query_limit = 3LL * t;

    log_metrics();

    cout << t << endl;

    for (int i = 0; i < t; ++i) {

        int p = inf.readInt();
        long long m = inf.readLong();

        int local_queries = 0;
        bool case_solved = false;

        while (!case_solved) {
            string token;

            if (!(cin >> token)) {
                finish(_wa, format("Unexpected EOF waiting for query or answer on case %d", i + 1));
            }

            if (token == "!") {

                int ans_p;
                long long ans_m;
                if (!(cin >> ans_p >> ans_m)) {
                    finish(_wa, format("Malformatted answer parameters on case %d", i + 1));
                }

                if (ans_p == p && ans_m == m) {
                    case_solved = true;
                } else {
                    finish(_wa, format("Wrong answer on case %d. Expected p=%d, m=%lld; Found p=%d, m=%lld",
                                       i + 1, p, m, ans_p, ans_m));
                }
            } else {

                string s;
                if (token == "?") {
                    if (!(cin >> s)) {
                        finish(_wa, format("Unexpected EOF reading query string on case %d", i + 1));
                    }
                } else {

                    s = token;
                }

                queries++;
                local_queries++;
                log_metrics();

                if (local_queries > 3) {
                    finish(_wa, format("Query limit exceeded on case %d (max 3)", i + 1));
                }

                if (s.length() > 50) {
                    finish(_wa, format("Query string too long on case %d (max 50)", i + 1));
                }

                long long hash_val = 0;
                long long p_pow = 1;
                for (char c : s) {
                    if (c < 'a' || c > 'z') {
                        finish(_wa, format("Invalid character '%c' in query on case %d", c, i + 1));
                    }
                    int ord = c - 'a' + 1;

                    long long term = (long long)((__int128)ord * p_pow % m);
                    hash_val = (hash_val + term) % m;

                    p_pow = (long long)((__int128)p_pow * p % m);
                }

                cout << hash_val << endl;
            }
        }
    }

    finish(_ok, "All test cases passed");
    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

static long long queries_count = 0;
static long long query_limit = 0;

static void log_metrics() {
    try {
        tout << "queries=" << queries_count << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {}
}

static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

struct LCG {
    unsigned long long state;
    LCG(unsigned long long seed = 123456789) : state(seed) {}
    unsigned int next() {
        state = state * 6364136223846793005ULL + 1;
        return state >> 33;
    }
    long long nextSkip(long long l, long long r) {
        if (l > r) return l;
        unsigned long long v = ((unsigned long long)next() << 32) ^ next();
        return l + (v % (r - l + 1));
    }
};

struct Case {
    int p;
    long long m;
};

long long compute_hash(const string& s, int p, long long m) {
    long long h = 0;
    long long p_pow = 1;
    for (char c : s) {
        int ord = c - 'a' + 1;

        long long term = (long long)((__int128)ord * p_pow % m);
        h = (h + term) % m;
        p_pow = (long long)((__int128)p_pow * p % m);
    }
    return h;
}

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    int t = inf.readInt();

    cout << t << endl;

    query_limit = (long long)t * 3;

    inf.skipBlanks();
    bool fixed_mode = !inf.eof();

    vector<Case> fixed_cases;
    if (fixed_mode) {
        for(int i = 0; i < t; ++i) {
            int p = inf.readInt();
            long long m = inf.readLong();
            fixed_cases.push_back({p, m});
        }
    }

    LCG rng(8888);

    for (int test_idx = 0; test_idx < t; ++test_idx) {

        int case_queries = 0;
        vector<Case> pool;

        vector<pair<string, long long>> history;

        if (fixed_mode) {
            pool.push_back(fixed_cases[test_idx]);
        } else {

            for (int p = 27; p <= 50; ++p) {

                for (int k = 2; k <= 8; ++k) pool.push_back({p, (long long)p + k});

                pool.push_back({p, 2000000000LL});
                pool.push_back({p, 1999999999LL});
                pool.push_back({p, 1000000007LL});

                for (int k = 0; k < 150; ++k) {
                    long long m = rng.nextSkip(p + 2, 2000000000LL);
                    pool.push_back({p, m});
                }
            }
        }

        while (true) {
            string type;
            if (!(cin >> type)) {
                finish(_wa, "Unexpected end of stream from contestant");
            }

            if (type == "!") {
                int ans_p;
                long long ans_m;
                if (!(cin >> ans_p >> ans_m)) {
                    finish(_wa, "Malformed answer parameters");
                }

                if (ans_p <= 26 || ans_p > 50) finish(_wa, "p out of range [27, 50]");
                if (ans_m <= ans_p + 1 || ans_m > 2000000000LL) finish(_wa, "m out of range (p+1, 2e9]");

                for (auto& h : history) {
                    long long expected = compute_hash(h.first, ans_p, ans_m);
                    if (expected != h.second) {
                        finish(_wa, "Answer inconsistent with previous query responses");
                    }
                }

                break;
            } else if (type == "?") {
                string s;
                cin >> s;

                if (s.empty() || s.length() > 50) finish(_wa, "Invalid string length (must be 1..50)");
                for (char c : s) {
                    if (c < 'a' || c > 'z') finish(_wa, "Invalid characters in string (must be lowercase latin)");
                }

                case_queries++;
                queries_count++;
                if (case_queries > 3) {
                    finish(_wa, "Query limit exceeded (max 3 per test case)");
                }

                long long reply = -1;

                if (pool.empty()) {

                    reply = 0;
                } else {

                    vector<pair<long long, int>> replies;
                    replies.reserve(pool.size());
                    for (int k = 0; k < (int)pool.size(); ++k) {
                        replies.push_back({compute_hash(s, pool[k].p, pool[k].m), k});
                    }

                    sort(replies.begin(), replies.end());

                    long long best_r = -1;
                    int max_cnt = -1;

                    if (!replies.empty()) {
                        long long curr_r = replies[0].first;
                        int curr_cnt = 1;
                        best_r = curr_r;
                        max_cnt = 1;

                        for (size_t k = 1; k < replies.size(); ++k) {
                            if (replies[k].first == curr_r) {
                                curr_cnt++;
                            } else {
                                if (curr_cnt > max_cnt) {
                                    max_cnt = curr_cnt;
                                    best_r = curr_r;
                                }
                                curr_r = replies[k].first;
                                curr_cnt = 1;
                            }
                        }
                        if (curr_cnt > max_cnt) {
                            max_cnt = curr_cnt;
                            best_r = curr_r;
                        }
                    }

                    reply = best_r;

                    vector<Case> new_pool;
                    new_pool.reserve(max_cnt);

                    auto it1 = lower_bound(replies.begin(), replies.end(), make_pair(reply, -1));
                    auto it2 = upper_bound(replies.begin(), replies.end(), make_pair(reply, 2147483647));

                    for (auto it = it1; it != it2; ++it) {
                        new_pool.push_back(pool[it->second]);
                    }
                    pool = move(new_pool);
                }

                cout << reply << endl;

                history.push_back({s, reply});
            } else {
                finish(_wa, "Invalid query format (expected ? or !)");
            }
        }
    }

    finish(_ok, "Correct");
    return 0;
}

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

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

    string mode = opt<string>("mode", "non");

    int t = opt<int>("t", 100);

    if (mode == "adp") {
        cout << t << endl;
        return 0;
    }

    long long seed_val = 0;
    try {
        if (argc > 1) seed_val = stoll(string(argv[1]));
    } catch (...) {
        seed_val = 0;
    }

    vector<pair<int, long long>> cases;

    if (seed_val == 1) {

        cases.push_back({27, 29});
        cases.push_back({50, 2000000000LL});
        cases.push_back({27, 2000000000LL});
        cases.push_back({50, 52});
    } else if (seed_val == 2) {

        cases.push_back({47, 1000000007LL});
        cases.push_back({50, 1000000009LL});
        cases.push_back({31, 998244353LL});
    } else if (seed_val == 3) {

        cases.push_back({30, 32});
        cases.push_back({50, 100});
        cases.push_back({40, 42});
    }

    while ((int)cases.size() < t) {

        int p = rnd.next(27, 50);
        long long m;

        int type = rnd.next(1, 100);

        if (type <= 5) {

            m = p + 2;
        } else if (type <= 10) {

            m = 2000000000LL;
        } else if (type <= 25) {

            m = rnd.next(2000000000LL - 10000, 2000000000LL);
        } else if (type <= 60) {

            m = rnd.next((long long)p + 2, (long long)p + 5000);
        } else {

            m = rnd.next((long long)p + 2, 2000000000LL);
        }

        cases.push_back({p, m});
    }

    shuffle(cases.begin(), cases.end());

    cout << t << endl;
    for (int i = 0; i < t; i++) {
        cout << cases[i].first << " " << cases[i].second << "\n";
    }

    return 0;
}