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;
vector<pair<int, int>> v;
queue<int> q;
int rec[2005];
bool vis[2005], isedge[2005][2005];
void solve() {
  int n, n1, M, cnt = 0, nxt;
  scanf("%d", &n);
  n1 = n - 1;
  v.clear();
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; ++i) vis[i] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) isedge[i][j] = 0;
  int x = (rand() % n) + 1;
  printf("? %d\n", x);
  fflush(stdout);
  M = -1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &rec[i]);
    M = max(M, rec[i]);
    if (rec[i] == 1) {
      v.push_back(make_pair(x, i));
      isedge[x][i] = isedge[i][x] = 1;
      ++cnt;
      nxt = i;
    }
  }
  if (cnt != 1) {
    for (int i = 2; i <= M; i += 2) {
      for (int j = 1; j <= n; ++j) {
        if (rec[j] == i) q.push(j);
      }
    }
  } else {
    int c2 = 0;
    for (int i = 1; i <= n; ++i)
      if (rec[i] == 2) ++c2;
    if (c2 == n - 2) {
      for (int i = 1; i <= n; ++i)
        if (rec[i] == 2) {
          v.push_back(make_pair(nxt, i));
          isedge[nxt][i] = isedge[i][nxt] = 1;
        }
    } else {
      for (int i = 2; i <= M; i += 2) {
        for (int j = 1; j <= n; ++j) {
          if (rec[j] == i) q.push(j);
        }
      }
    }
  }
  int ask;
  while (v.size() != n - 1) {
    ask = q.front();
    q.pop();
    printf("? %d\n", ask);
    fflush(stdout);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &rec[i]);
      if (rec[i] == 1 && isedge[ask][i] == 0) {
        v.push_back(make_pair(ask, i));
        isedge[ask][i] = isedge[i][ask] = 1;
      }
    }
  }
  printf("!\n");
  fflush(stdout);
  for (int i = 0; i < n1; ++i) {
    printf("%d %d\n", v[i].first, v[i].second);
    fflush(stdout);
  }
  return;
}
int main() {
  solve();
  return 0;
}
