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 from[100005], to[100005], num;
signed main() {
  long long n;
  cin >> n;
  cout << "? 1" << endl;
  fflush(stdout);
  long long a[n + 1], ji = 0, ou = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == 1) {
      continue;
    }
    if (a[i] % 2 == 0) {
      ou++;
    } else {
      ji++;
    }
    if (a[i] == 1) {
      num++;
      from[num] = 1;
      to[num] = i;
    }
  }
  if (ji >= ou) {
    for (long long i = 1; i <= n; i++) {
      if (a[i] % 2 == 0 && i != 1) {
        cout << "? " << i << endl;
        fflush(stdout);
        for (long long j = 1; j <= n; j++) {
          long long l;
          cin >> l;
          if (l == 1) {
            num++;
            from[num] = i;
            to[num] = j;
          }
        }
      }
    }
    cout << "!" << endl;
    for (long long i = 1; i <= num; i++) {
      cout << from[i] << " " << to[i];
    }
    cout << endl;
    fflush(stdout);
  } else {
    for (long long i = 1; i <= n; i++) {
      if (a[i] % 2 == 1) {
        cout << "? " << i << endl;
        fflush(stdout);
        for (long long j = 1; j <= n; j++) {
          long long l;
          cin >> l;
          if (l == 1 && j != 1) {
            num++;
            from[num] = i;
            to[num] = j;
          }
        }
      }
    }
    cout << "!" << endl;
    for (long long i = 1; i <= num; i++) {
      cout << from[i] << " " << to[i] << endl;
    }
    fflush(stdout);
  }
  return 0;
}
