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 inf = 1e18 + 100, mod = 1e9 + 7, n;
int mat[2001][2001];
vector<long long> factors(long long n) {
  vector<long long> ans;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ans.push_back(i);
      if (i * i != n) ans.push_back(n / i);
    }
  }
  return ans;
}
int primeFactors(int n) {
  long long ans = 0;
  while (n % 2 == 0) {
    ans++;
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      ans++;
      n = n / i;
    }
  }
  if (n > 2) ans++;
  return ans;
}
int main() {
  int t = 1;
  for (int T = 1; T <= t; T++) {
    long long n;
    cin >> n;
    long long queries = ceil(n / 2.0);
    set<int> set_;
    vector<bool> visited(n + 2, false);
    set<int>::iterator it;
    vector<int> v[n + 1];
    int dist[n + 5], curr = 1, white = 0, red = 0;
    queries--;
    cout << "? " << curr << endl;
    fflush(stdout);
    for (int i = 1; i <= n; i++) {
      cin >> dist[i];
      if (dist[i] == 1) mat[1][i] = 1;
      if (dist[i] & 1)
        red++;
      else
        white++;
    }
    if (white <= ceil(n / 2.0)) {
      for (int i = 2; i <= n; i++)
        if (dist[i] % 2 == 0) set_.insert(i);
    } else {
      for (int i = 2; i <= n; i++)
        if (dist[i] & 1) set_.insert(i);
    }
    while (queries--) {
      it = set_.begin();
      int curr = *it;
      set_.erase(it);
      cout << "? " << curr << endl;
      fflush(stdout);
      for (int i = 1; i <= n; i++) {
        cin >> dist[i];
        if (dist[i] == 1) mat[curr][i] = 1;
      }
    }
    cout << "!" << endl;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++)
        if (i < j && mat[i][j]) cout << i << " " << j << endl;
    }
  }
}
