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 deg[2005], dis[2005];
int fa[2005];
void solve(int u, int n) {
  printf("? %d\n", u);
  fflush(stdout);
  for (int i = 1; i <= n; i++) scanf("%d", &dis[i]);
  if (u == 1)
    for (int i = 1; i <= n; i++) deg[i] = dis[i];
}
int main(void) {
  int n;
  scanf("%d", &n);
  solve(1, n);
  int cnt0 = 0, cnt1 = 0;
  for (int i = 2; i <= n; i++) {
    if (deg[i] % 2 == 0)
      cnt0++;
    else
      cnt1++;
  }
  int c = 1;
  if (cnt0 < cnt1) c = 0;
  for (int i = 2; i <= n; i++) {
    if (deg[i] % 2 == c) {
      printf("? %d\n", i);
      fflush(stdout);
      for (int j = 1; j <= n; j++) scanf("%d", &dis[j]);
      for (int j = 1; j <= n; j++) {
        if (dis[j] == 1) {
          if (deg[j] > deg[i])
            fa[j] = i;
          else
            fa[i] = j;
        }
      }
    }
  }
  puts("!");
  for (int i = 2; i <= n; i++) {
    printf("%d %d\n", i, fa[i]);
  }
  fflush(stdout);
}
