#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int n, par[N], sz[N], q = 0, a = 0, b = 0;
int find(int v) {
return par[v] == v ? v : (par[v] = find(par[v]));
}
bool merge(int u, int v) {
u = find(u), v = find(v);
if(u == v) return 0;
par[v] = u;
sz[u] += sz[v];
return 1;
}
map<vector<int>, int> memo;
bool found(int p, int l, int x) {
vector<int> ask(n + 1);
ask[p] = 1;
int edges = 0;
for(int i = l + 1; i <= x; i++) {
if(find(i) != find(p)) {
ask[i] = 2;
edges++;
}
}
if(memo.count(ask)) {
return memo[ask] < b * edges;
}
q++;
if(q > 2000) assert(0);
cout << "? ";
for(int i = 1; i <= n; i++) {
cout << ask[i] << " ";
}
cout << endl;
int z;
cin >> z;
memo[ask] = z;
return z < b * edges;
}
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++) par[i] = i, sz[i] = 1;
cout << "? 1 2 ";
for(int i = 3; i <= n; i++) cout << "0 ";
cout << endl;
cin >> a;
for(int i = 1; i <= n && b == 0; i++) {
cout << "? ";
for(int j = 1; j <= n; j++) {
if(i != j) cout << 2 << " ";
else cout << 1 << " ";
}
cout << endl;
int z;
cin >> z;
if(a * (n - 1) != z) {
// a * x + b * y = z
// a * j + b * (n - 1 - j) = z
// b = (z - a * j) / (n - 1 - j)
for(int j = 0; j <= n - 1; j++) {
if((z - a * j) % (n - 1 - j) == 0) {
b = (z - a * j) / (n - 1 - j);
break;
}
}
if(a > b) swap(a, b);
}
}
if(b == 0) {
cout << "! " << n - 1 << '\n';
for(int i = 2; i <= n; i++) {
cout << 1 << " " << i << '\n';
}
cout << flush;
return 0;
}
// cout << a << " " << b << endl;
int ones = 0;
vector<pair<int,int>> edges;
for(int i = 1; i <= n && ones < n - 1; i++) {
int z = i;
while(1) {
int l = z + 1, r = n, x = -1;
while(l <= r) {
int mid = (l + r) / 2;
if(found(i, z, mid)) {
r = mid - 1, x = mid;
} else {
l = mid + 1;
}
}
z = x;
ones += x != -1;
if(x == -1) break;
edges.push_back({i, x});
merge(i, x);
if(ones == n - 1) break;
}
}
cout << "! " << n - 1 << '\n';
set<int> parents;
for(int i = 1; i <= n; i++) {
parents.insert(find(i));
}
for(int i = 1; i <= n && edges.size() < n - 1; i++) {
if(merge(find(i), *parents.begin())) {
edges.push_back({*parents.begin(), find(i)});
assert(*parents.begin() < find(i));
}
}
assert(edges.size() == n - 1);
for(auto [u, v] : edges) {
if(u > v) cout << v << " " << u << '\n';
else cout << u << " " << v << '\n';
}
cout << flush;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTiA9IDIwMDsKCmludCBuLCBwYXJbTl0sIHN6W05dLCBxID0gMCwgYSA9IDAsIGIgPSAwOwoKaW50IGZpbmQoaW50IHYpIHsKCXJldHVybiBwYXJbdl0gPT0gdiA/IHYgOiAocGFyW3ZdID0gZmluZChwYXJbdl0pKTsKfQoKYm9vbCBtZXJnZShpbnQgdSwgaW50IHYpIHsKCXUgPSBmaW5kKHUpLCB2ID0gZmluZCh2KTsKCWlmKHUgPT0gdikgcmV0dXJuIDA7CgoJcGFyW3ZdID0gdTsKCXN6W3VdICs9IHN6W3ZdOwoJcmV0dXJuIDE7Cn0KCm1hcDx2ZWN0b3I8aW50PiwgaW50PiBtZW1vOwoKYm9vbCBmb3VuZChpbnQgcCwgaW50IGwsIGludCB4KSB7Cgl2ZWN0b3I8aW50PiBhc2sobiArIDEpOwoJYXNrW3BdID0gMTsKCWludCBlZGdlcyA9IDA7Cglmb3IoaW50IGkgPSBsICsgMTsgaSA8PSB4OyBpKyspIHsKCQlpZihmaW5kKGkpICE9IGZpbmQocCkpIHsKCQkJYXNrW2ldID0gMjsKCQkJZWRnZXMrKzsKCQl9Cgl9CgoJaWYobWVtby5jb3VudChhc2spKSB7CgkJcmV0dXJuIG1lbW9bYXNrXSA8IGIgKiBlZGdlczsKCX0KCXErKzsKCWlmKHEgPi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