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 long long N = 2005;
vector<long long> ans[N];
long long p[N];
vector<long long> c[N];
vector<bool> vis;
long long n;
void get(long long node) {
  vis[node] = true;
  cout << "? " << node + 1 << endl;
  ans[node].resize(n);
  for (auto &x : ans[node]) cin >> x;
  for (long long i = 0; i < n; ++i) {
    if (ans[node][i] == 1) {
      if (vis[i]) {
        p[node] = i;
        c[i].push_back(node);
      } else {
        p[i] = node;
        c[node].push_back(i);
        vis[i] = true;
      }
    }
  }
}
int32_t main() {
  cin >> n;
  vis.resize(n, false);
  get(0);
  vector<long long> cnt(2, 0);
  for (long long i = 1; i < n; ++i) {
    cnt[ans[0][i] % 2]++;
  }
  vector<pair<long long, long long>> cand;
  for (long long i = 1; i < n; ++i) {
    if (cnt[0] >= cnt[1] && ans[0][i] % 2 == 0)
      cand.push_back({ans[0][i], i});
    else if (cnt[1] > cnt[0] && ans[0][i] % 2 == 1)
      cand.push_back({ans[0][i], i});
  }
  sort((cand).begin(), (cand).end());
  for (auto &c : cand) {
    get(c.second);
  }
  cout << "!" << endl;
  for (long long i = 1; i < n; ++i) {
    cout << i + 1 << ' ' << p[i] + 1 << endl;
  }
}
