5
5 3
2 4
3 1
4 5
 4
2 4
3 2
2 1
 5
5 3
2 4
3 1
4 5
 2
1 2
 4
3 4
2 3
3 1
 10
8 10
2 9
7 8
4 1
7 3
4 7
2 5
2 4
4 6
 5
3 4
3 2
3 1
1 5
 3
1 2
2 3
 5
1 2
1 3
1 4
1 5

1 2
2 3
2 4
 1 3
2 4
3 5
4 5
 1 2
 1 3
2 3
3 4
 1 4
2 4
2 5
2 9
3 7
4 6
4 7
7 8
8 10
 1 3
1 5
2 3
3 4
 1 2
2 3
 1 2
1 3
1 4
1 5

#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e3 + 5;
int n;
int bac[N];
int par[N];
vector<pair<int, int> > res;
int d[N], check[N];
vector<int> a[N];
int finds(int u) {
  if (par[u] < 0)
    return u;
  else
    return (par[u] = finds(par[u]));
}
int join(int u, int v) {
  u = finds(u);
  v = finds(v);
  if (u == v) return 0;
  if (par[v] < par[u]) swap(u, v);
  par[u] += par[v];
  par[v] = u;
  return 1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    par[i] = -1;
    bac[i] = 0;
    check[i] = 0;
  }
  bac[0] = 2000;
  while (1) {
    if ((int)res.size() == n - 1) break;
    int u = 0;
    for (int i = 1; i <= n; i++) {
      if (check[i]) continue;
      if (bac[i] < bac[u]) {
        u = i;
      }
    }
    if (u == 0) break;
    check[u] = 1;
    cout << "? " << u << endl;
    cout.flush();
    for (int i = 0; i <= n; i++) {
      a[i].clear();
    }
    for (int i = 1; i <= n; i++) {
      int x;
      cin >> x;
      a[x].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
      if ((int)a[i - 1].size() == 1) {
        for (int v : a[i]) {
          int val = join(u, v);
          if (val == 1) {
            res.push_back(make_pair(u, v));
            bac[u] += 1;
            bac[v] += 1;
          }
        }
        if ((int)a[i].size()) u = a[i].back();
      } else
        break;
    }
  }
  cout << "!" << endl;
  cout.flush();
  for (auto i : res) {
    cout << i.first << " " << i.second << endl;
    cout.flush();
  }
}
