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 M = 1e9 + 7;
long long M2 = 998244353;
void show(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void solve() {
  long long n;
  cin >> n;
  long long edge = 0;
  long long node = 0;
  vector<vector<long long>> graph(n + 1, vector<long long>(n + 1, 0));
  cout << "? " << 1 << endl;
  vector<long long> dist(n), odd, even;
  for (long long i = 0; i < n; i++) {
    cin >> dist[i];
    if (dist[i] == 0) continue;
    if (dist[i] == 1) {
      graph[1][i + 1] = 1;
      edge++;
    }
    if (dist[i] % 2)
      even.push_back(i + 1);
    else
      odd.push_back(i + 1);
  }
  while (edge < n - 1) {
    cout << "? " << even[node] << endl;
    for (long long i = 0; i < n; i++) cin >> dist[i];
    for (long long i = 0; i < n; i++) {
      if (dist[i] == 1) {
        if (graph[i + 1][even[node]] == 0 and graph[even[node]][i + 1] == 0)
          graph[i + 1][even[node]] = 1;
        edge++;
      }
    }
    node++;
  }
  cout << "!\n";
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (graph[i][j]) {
        cout << i << " " << j << endl;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1, Q = 1;
  while (T--) {
    solve();
  }
  return 0;
}
