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;
using namespace chrono;
void mark(queue<int>& q, set<pair<int, int>>& s, vector<int>& vis, int& cnt,
          int n) {
  int k = q.size();
  for (int i = 0; i < k; i++) {
    if (cnt >= (n + 1) / 2) break;
    int curr = q.front();
    vis[curr] = 1;
    q.pop();
    cout << "? " << curr << '\n';
    cout.flush();
    vector<int> a(n + 1);
    int cnt1 = 0, cnt2 = 0;
    for (int j = 1; j <= n; j++) {
      cin >> a[j];
      if (a[j] == 1 && !vis[j]) {
        s.insert({curr, j});
        cnt1++;
      }
      if (a[j] == 2 && !vis[j]) {
        cnt2++;
      }
    }
    if (cnt1 < cnt2) {
      for (int j = 1; j <= n; j++) {
        if (a[j] == 1 && !vis[j]) {
          q.push(j);
        }
      }
    } else {
      for (int j = 1; j <= n; j++) {
        if (a[j] == 2 && !vis[j]) {
          q.push(j);
        }
      }
    }
    cnt++;
  }
}
void solve() {
  int n;
  cin >> n;
  set<pair<int, int>> s;
  vector<int> vis(n + 1, 0);
  int root = 1, cnt = 0;
  queue<int> q;
  q.push(root);
  while (cnt < (n + 1) / 2 && !q.empty()) {
    mark(q, s, vis, cnt, n);
  }
  cout << "!" << '\n';
  for (auto it : s) {
    cout << it.first << " " << it.second << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  auto start = high_resolution_clock::now();
  int t = 1;
  for (int test = 1; test <= t; test++) {
    solve();
  }
  auto end = high_resolution_clock::now();
  auto duration = duration_cast<milliseconds>(end - start);
  return 0;
}
