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;
vector<long long int> adj[100001];
long long int visit[100001];
int main() {
  {
    long long int n;
    cin >> n;
    queue<long long int> q;
    q.push(1);
    long long int cnt = 0, cnt1 = 0, limit = (n / 2) + (n % 2);
    vector<int> col[2];
    cout << "? 1" << endl;
    long long int a[n];
    for (int i = 0; i < n; i++) cin >> a[i], col[a[i] % 2].push_back(i + 1);
    int c = 0;
    if (col[1].size() < col[c].size()) c = 1;
    for (auto it : col[c]) {
      long long int a[n];
      cout << "? " << it << endl;
      for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 1) {
          adj[it].push_back(i + 1);
        }
      }
    }
    cout << "!\n";
    for (int i = 1; i < n + 1; i++) {
      for (auto it : adj[i]) cout << i << " " << it << endl;
    }
  }
  return 0;
}
