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;
int n;
vector<int> query(int i) {
  printf("? %d\n", i);
  fflush(stdout);
  vector<int> v;
  v.push_back(6);
  for (int i = 1; i <= n; i++) {
    int g;
    scanf("%d", &g);
    v.push_back(g);
  }
  return v;
}
pair<int, int> make(int i, int j) {
  if (i < j) {
    return {i, j};
  } else {
    return make(j, i);
  }
}
int32_t main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  scanf("%d", &n);
  vector<int> lvl[n + 3];
  set<pair<int, int>> edges;
  int level[n + 1];
  int mark[n + 1];
  for (int i = 1; i <= n; i++) {
    mark[i] = 0;
  }
  vector<int> v = query(1);
  for (int i = 1; i <= n; i++) {
    lvl[v[i]].push_back(i);
    level[i] = v[i];
  }
  for (auto el : lvl[1]) {
    pair<int, int> P = make(el, 1);
    edges.insert(P);
    mark[el] = 1;
  }
  for (int i = 2; i <= n + 1; i++) {
    int par;
    for (auto el : lvl[i]) {
      if (mark[el] == 0) {
        vector<int> temp = query(el);
        for (int p = 1; p <= n; p++) {
          if (level[p] == (i - 1) && temp[p] == 1) {
            par = p;
            pair<int, int> P = make(par, el);
            edges.insert(P);
            mark[el] = 1;
          }
          if (level[p] == i && temp[p] == 2) {
            mark[p] = 1;
            pair<int, int> P = make(par, p);
            edges.insert(P);
          }
          if (level[p] == i + 1 && temp[p] == 1) {
            mark[p] = 1;
            pair<int, int> P = make(el, p);
            edges.insert(P);
          }
        }
      }
    }
  }
  printf("!\n");
  auto it = edges.begin();
  while (it != edges.end()) {
    printf("%d %d\n", it->first, it->second);
    it++;
  }
  fflush(stdout);
}
