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;
long long n;
long long a[2010];
long long dep[2010], fa[2010], mxd;
vector<long long> g[2010], f[2010];
template <typename Tp>
void read(Tp &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
signed main() {
  read(n);
  cout << "? 1" << endl;
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    dep[i] = a[i];
    if (dep[i] == 1) g[1].push_back(i);
    f[a[i]].push_back(i);
    if (dep[i] & 1) sum++;
    mxd = max(mxd, dep[i]);
  }
  long long i;
  if (sum < n - 1 - sum)
    i = 1;
  else
    i = 2;
  for (; i <= mxd; i += 2) {
    for (unsigned j = 0; j < f[i].size(); j++) {
      long long x = f[i][j];
      cout << "? " << x << endl;
      for (long long k = 1; k <= n; k++) {
        cin >> a[k];
        if (a[k] == 1) {
          if (dep[k] == i - 1) {
            if (k != 1) g[k].push_back(x), fa[x] = k;
          } else
            g[x].push_back(k);
        }
      }
      for (long long k = 1; k <= n; k++)
        if (a[k] == 2 && dep[k] == dep[fa[x]] + 1) g[fa[x]].push_back(k);
    }
  }
  cout << "!" << endl;
  for (long long i = 1; i <= n; i++) {
    for (unsigned j = 0; j < g[i].size(); j++)
      cout << i << " " << g[i][j] << endl;
  }
  return 0;
}
