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;
int main() {
  int n;
  cin >> n;
  queue<int> qu;
  qu.push(1);
  vector<int> adj[n + 5];
  int flag = -1;
  bool vis[n + 5];
  memset(vis, 0, sizeof vis);
  while (!qu.empty()) {
    int x = qu.front();
    qu.pop();
    cout << "? " << x << endl;
    cout.flush();
    vis[x] = 1;
    int a[n + 10], even = 0, odd = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      a[i] % 2 == 0 ? even++ : odd++;
    }
    if (flag == -1) {
      if (even > odd)
        flag = 0;
      else
        flag = 1;
    }
    if (flag == 1) {
      for (int i = 1; i <= n; i++)
        if (a[i] == 1 && !vis[i]) qu.push(i), adj[x].push_back(i);
    } else {
      for (int i = 1; i <= n; i++) {
        if (a[i] == 2 && !vis[i]) qu.push(i);
        if (a[i] == 1 && !vis[i]) adj[x].push_back(i);
      }
    }
  }
  cout << "!" << endl;
  map<pair<int, int>, bool> mp;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < adj[i].size(); j++) {
      int u = i, v = adj[i][j];
      if (u > v) swap(u, v);
      if (mp.count({u, v})) continue;
      cout << u << " " << v << endl;
      mp[{u, v}] = 1;
    }
  return 0;
}
