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;
void doit() {
  long long n;
  cin >> n;
  cout.flush();
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) {
    a[i] = -1;
  }
  long long gd1[n + 1];
  cout << "? " << 1 << endl;
  cout.flush();
  for (long long j = 1; j <= n; j++) {
    cin >> gd1[j];
  }
  vector<long long> d1out;
  vector<long long> d2out;
  for (long long j = 1; j <= n; j++) {
    if (gd1[j] == 1) {
      d1out.push_back(j);
    }
    if (gd1[j] == 2) {
      d2out.push_back(j);
    }
  }
  if (((long long)(d1out.size())) == 1) {
    a[d1out[0]] = d1out[0];
    a[1] = d1out[0];
    for (long long j = 0; j <= ((long long)(d2out.size())) - 1; j++) {
      a[d2out[j]] = d1out[0];
    }
  } else {
    a[1] = 1;
    for (long long j = 0; j <= ((long long)(d1out.size())) - 1; j++) {
      a[d1out[j]] = 1;
    }
  }
  long long limit = n / 2;
  if (n % 2 == 1) {
    limit++;
  }
  for (long long i = 1; i <= n; i++) {
    if ((a[i] == -1) && (a[1] == 1 && gd1[i] % 2 == 0) ||
        (a[1] != 1 && gd1[i] % 2 == 1)) {
      limit--;
      if (limit < 0) {
        while (1) {
        }
      }
      cout << "? " << i << endl;
      cout.flush();
      vector<long long> d1;
      vector<long long> d2;
      long long dis[n + 1];
      for (long long j = 1; j <= n; j++) {
        cin >> dis[j];
        if (dis[j] == 1) {
          d1.push_back(j);
        }
        if (dis[j] == 2) {
          d2.push_back(j);
        }
      }
      if (((long long)(d1.size())) == 1) {
        a[i] = d1[0];
        for (long long j = 0; j <= ((long long)(d2.size())) - 1; j++) {
          if (gd1[d1[0]] < gd1[d2[j]]) {
            a[d2[j]] = d1[0];
          } else {
            a[d1[0]] = d2[j];
          }
        }
      } else {
        for (long long j = 0; j <= ((long long)(d1.size())) - 1; j++) {
          if (gd1[i] < gd1[d1[j]]) {
            a[d1[j]] = i;
          } else {
            a[i] = d1[j];
          }
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (a[i] == -1) {
      limit--;
      if (limit < 0) {
        while (1) {
        }
      }
      cout << "? " << i << endl;
      cout.flush();
      vector<long long> d1;
      vector<long long> d2;
      long long dis[n + 1];
      for (long long j = 1; j <= n; j++) {
        cin >> dis[j];
        if (dis[j] == 1) {
          d1.push_back(j);
        }
        if (dis[j] == 2) {
          d2.push_back(j);
        }
      }
      if (((long long)(d1.size())) == 1) {
        a[i] = d1[0];
        for (long long j = 0; j <= ((long long)(d2.size())) - 1; j++) {
          if (gd1[d1[0]] < gd1[d2[j]]) {
            a[d2[j]] = d1[0];
          } else {
            a[d1[0]] = d2[j];
          }
        }
      } else {
        for (long long j = 0; j <= ((long long)(d1.size())) - 1; j++) {
          if (gd1[i] < gd1[d1[j]]) {
            a[d1[j]] = i;
          } else {
            a[i] = d1[j];
          }
        }
      }
    }
  }
  cout << "!" << endl;
  for (long long i = 1; i <= n; i++) {
    if (a[i] != i) {
      cout << i << " " << a[i] << endl;
    }
  }
  cout.flush();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    doit();
  }
}
