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;
const int N = 2000 + 10;
int n, a[N][N], cnt[2];
pair<int, int> ans[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  cout << "? " << 1 << endl;
  for (int i = 1; i <= n; i++) {
    cin >> a[1][i];
    cnt[a[1][i] % 2]++;
  }
  if (cnt[0] < cnt[1]) {
    int j = 1;
    for (int i = 1; i <= n; i++) {
      if (a[1][i] == 1) {
        ans[j].first = 1;
        ans[j].second = i;
        j++;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (a[1][i] % 2 == 0) {
        cout << "? " << i << endl;
        for (int k = 1; k <= n; k++) {
          cin >> a[i][k];
          if (a[i][k] == 1) {
            ans[j].first = min(i, k);
            ans[j].second = max(k, i);
            j++;
          }
        }
      }
    }
    cout << "!" << endl;
    for (int i = 1; i < n; i++) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  } else {
    int j = 1;
    for (int i = 1; i <= n; i++) {
      if (a[1][i] % 2 == 1) {
        cout << "? " << i << endl;
        for (int k = 1; k <= n; k++) {
          cin >> a[i][k];
          if (a[i][k] == 1) {
            ans[j].first = min(i, k);
            ans[j].second = max(k, i);
            j++;
          }
        }
      }
    }
    for (int i = 1; i <= n - 1; i++) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
  cout.flush();
  return 0;
}
