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 read() {
  int res = 0, fs = 1;
  char c = getchar();
  while (!(c >= '0' && c <= '9')) {
    if (c == '-') fs = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * fs;
}
void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int n, cnt, m, a[5010], ans, tmp, k;
vector<int> u, v;
int vis[20005];
int roota[20005];
void dg(int x) {
  cout << "? " << x << '\n';
  cout.flush();
  for (int i = 1; i <= n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp == 1 && !vis[i]) vis[i] = 1, u.push_back(i), v.push_back(x);
  }
}
int main() {
  cin >> n;
  cout << "? " << 1 << '\n';
  cout.flush();
  for (int i = 1; i <= n; i++) {
    cin >> roota[i];
    if ((roota[i] % 2 == 1) && !vis[i]) cnt++, a[cnt] = i;
  }
  for (int i = 1; i <= cnt; i++) dg(a[i]);
  cout << "! \n";
  for (int i = 0; i < u.size(); i++) {
    cout << u[i] << ' ' << v[i] << '\n';
  }
  return 0;
}
