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 dr[8] = {-1, 0, +1, 0, -1, -1, +1, +1};
int dc[8] = {0, +1, 0, -1, -1, +1, -1, +1};
int kx[8] = {-1, +1, +1, -1, +2, +2, -2, -2};
int ky[8] = {+2, +2, -2, -2, -1, +1, +1, -1};
const int N = 400005;
int main() {
  int n;
  cin >> n;
  queue<int> q;
  map<int, int> mn;
  map<pair<int, int>, int> mm;
  vector<pair<int, int> > vec;
  cout << "? " << 1 << endl;
  int a[n + 1];
  int one = 0, two = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] == 1)
      one++;
    else if (a[i] == 2)
      two++;
  }
  int flag = 0;
  if (one <= two)
    flag = 2;
  else
    flag = 1;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == 1) {
      q.push(i);
    }
  }
  mn[1] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (mn[x]) continue;
    cout << "? " << x << endl;
    mn[x] = 1;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      if (a[i] == 1) {
        if (mm[{x, i}] == 0 && mm[{i, x}] == 0) {
          mm[{x, i}] = mm[{i, x}] = 1;
          vec.push_back({x, i});
        }
        mn[i] = 1;
      }
      if (a[i] == flag) {
        q.push(i);
      }
    }
  }
  cout << "! " << endl;
  for (auto i : vec) {
    cout << i.first << ' ' << i.second << endl;
  }
}
