Problem: cf1158_e
Difficulty: medium
Categories: graph, bit, search
Time limit: 1000 ms, memory limit: 256 MB

It is an interactive problem.

Vasya enjoys solving quizzes. He found a strange device and wants to know how it works.

This device encrypted with the tree (connected undirected graph without cycles) with $n$ vertices, numbered with integers from $1$ to $n$. To solve this quiz you should guess this tree.

Fortunately, this device can make one operation, using which you should guess the cipher. You can give the device an array $d_1, d_2, \ldots, d_n$ of non-negative integers. On the device, there are $n$ lamps, $i$-th of them is connected with $i$-th vertex of the tree. For all $i$ the light will turn on the $i$-th lamp, if there exist such vertex of the tree with number $j \neq i$ that $dist(i, j) \leq d_j$. Let's define $dist(i, j)$ as the distance between vertices $i$ and $j$ in tree or number of edges on the simple path between vertices $i$ and $j$.

Vasya wants to solve this quiz using $\leq 80$ operations with the device and guess the tree. Help him!

Interaction

In the beginning, your program should read one integer $n$ — the number of vertices of the tree which encrypts the device ($2 \leq n \leq 1000$).

After that, you can make several operations in the following format. To do operation print a symbol"?" (without quotes) and $n$ integers $d_1, d_2, \ldots, d_n$, separated by spaces after it. Please note, that for all $i$ you can only use the numbers, satisfying the inequality $0 \leq d_i < n$. After that, you should read a string $s$ with length $n$, consisting of symbols "0" and "1" (without quotes). For all $i$ the symbol $s_i$ is equal to "0", if the lamp on the device, connected with $i$-th vertex of the tree is switched off and "1" otherwise.

After several operations, you should print guessed tree. To do it print the only symbol "!" (without quotes). In the next $n-1$ lines print $2$ integers $a_i$, $b_i$ — indexes of the vertices connected by $i$-th edge of the tree. This numbers should satisfy the conditions $1 \leq a_i, b_i \leq n$ and $a_i \neq b_i$. This edges should form a tree, which is equal to the hidden tree. After that, your program should terminate.

It is guaranteed, that in each test the tree is fixed before and won't change depending on your program's operations.

Your program can make from $0$ to $80$ operations with the device and after that guess the tree equal with the hidden.

If your program will make more than $80$ operations it can get any verdict, because it will continue reading from closed input. If your program will make operation or print the answer in the incorrect format, it can get any verdict too. Be careful.

Don't forget to flush the output after printing questions and answers.

To flush the output, you can use:

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

Example

Input

```
5
00000
11011
11100
10010
```

Output

```
? 0 0 0 0 0
? 1 1 2 0 2
? 0 0 0 1 0
? 0 1 0 0 1
!
4 2
1 5
3 4
4 1
```

Note

It is a picture of the tree which encrypt the device from the first test:

 ![](https://espresso.codeforces.com/1dc4531527b158b99b5e3d06c9fa3256a0a87bca.png) 

It is a table of pairwise distances between vertices in this tree:

 ![](https://espresso.codeforces.com/83592cfb57350593c1207cd472a798b19b01b48a.png) 

* If you make operation where $d = [0, 0, 0, 0, 0]$, no lamp will switch on, because $dist(i, j) > 0$ for all $i \neq j$.
* If you make operation where $d = [1, 1, 2, 0, 2]$, all lamps except the lamp connected with the $3$-rd vertex will switch on. For example, lamp connected with the $1$-st vertex will switch on, because $dist(1, 5) = 1 \leq 2 = d_5$.
* If you make operation where $d = [0, 0, 0, 1, 0]$, all lamps except lamps connected with the $4$-th and $5$-th vertices will switch on.
* If you make operation where $d = [0, 1, 0, 0, 1]$, only lamps connected with the $1$-st and $4$-th vertices will switch on.

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

static int queries = 0;
static long long query_limit = -1;

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 n = inf.readInt();
    vector<vector<int>> g(n + 1);
    set<pair<int, int>> edges;
    if (inf.seekEof()) {
        
        for (int u = 1; u + 1 <= n; u++) {
            int v = u + 1;
            g[u].push_back(v);
            g[v].push_back(u);
            edges.insert({u, v});
        }
    } else {
        for (int i = 0; i < n - 1; i++) {
            int u = inf.readInt();
            int v = inf.readInt();
            g[u].push_back(v);
            g[v].push_back(u);
            if (u > v) {
                swap(u, v);
            }
            edges.insert({u, v});
        }
    }

    
    vector<vector<short>> dist(n + 1, vector<short>(n + 1, -1));
    for (int s = 1; s <= n; s++) {
        queue<int> q;
        dist[s][s] = 0;
        q.push(s);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int v : g[u]) {
                if (dist[s][v] != -1) {
                    continue;
                }
                dist[s][v] = short(dist[s][u] + 1);
                q.push(v);
            }
        }
    }

    query_limit = 80;

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

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

        if (cmd == "?") {
            queries++;
            if (queries > query_limit) {
                quit_with(_pe, "Too many operations");
            }

            vector<int> d(n + 1);
            for (int i = 1; i <= n; i++) {
                if (!(cin >> d[i])) {
                    quit_with(_pe, "Invalid query payload");
                }
                if (d[i] < 0 || d[i] >= n) {
                    quit_with(_pe, "d[i] out of range");
                }
            }

            string s(n, '0');
            for (int i = 1; i <= n; i++) {
                bool on = false;
                for (int j = 1; j <= n; j++) {
                    if (i == j) {
                        continue;
                    }
                    if (dist[i][j] <= d[j]) {
                        on = true;
                        break;
                    }
                }
                s[i - 1] = on ? '1' : '0';
            }
            cout << s << "\n" << flush;

        } else if (cmd == "!") {
            set<pair<int, int>> out;
            for (int i = 0; i < n - 1; i++) {
                int u, v;
                if (!(cin >> u >> v)) {
                    quit_with(_pe, "Missing edges");
                }
                if (!(1 <= u && u <= n && 1 <= v && v <= n && u != v)) {
                    quit_with(_pe, "Invalid edge");
                }
                if (u > v) {
                    swap(u, v);
                }
                out.insert({u, v});
            }
            if (out == edges) {
                quit_with(_ok, "Correct");
            }
            quit_with(_wa, "Wrong tree");

        } else {
            quit_with(_pe, "Unknown command: " + cmd);
        }
    }
}


Adaptive interactor (C++):

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

static vector<pair<int, int>> gen_path(int n) {
    vector<pair<int, int>> e;
    for (int i = 1; i + 1 <= n; i++) e.push_back({i, i + 1});
    return e;
}

static vector<pair<int, int>> gen_star(int n) {
    vector<pair<int, int>> e;
    for (int i = 2; i <= n; i++) e.push_back({1, i});
    return e;
}

static vector<pair<int, int>> gen_balanced(int n) {
    vector<pair<int, int>> e;
    for (int i = 2; i <= n; i++) e.push_back({i / 2, i});
    return e;
}

static vector<pair<int, int>> gen_random(int n) {
    vector<pair<int, int>> e;
    e.reserve(n - 1);
    for (int i = 2; i <= n; i++) {
        int p = rnd.next(1, i - 1);
        e.push_back({p, i});
    }
    return e;
}

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

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

    int n = 1000;
    if (seed == 1) n = 2;
    else if (seed == 2) n = 3;
    else if (seed <= 10) n = 50 + (int)seed * 10;
    n = max(2, min(1000, n));

    vector<pair<int, int>> edges;
    int kind = (int)(seed % 4);
    if (kind == 0) edges = gen_path(n);
    else if (kind == 1) edges = gen_star(n);
    else if (kind == 2) edges = gen_balanced(n);
    else edges = gen_random(n);

    cout << n << "\n";
    for (auto [u, v] : edges) cout << u << " " << v << "\n";
    return 0;
}