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 std::chrono;
using ii = pair<long long int, long long int>;
class prioritize {
 public:
  bool operator()(ii &p1, ii &p2) { return p1.first < p2.first; }
};
auto start_time = high_resolution_clock::now();
void time() { return; }
void ojudge() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  return;
}
int main() {
  ojudge();
  long long int n;
  cin >> n;
  queue<long long int> q;
  map<long long int, set<long long int>> v;
  q.push(1);
  set<long long int> vst;
  for (long long int Q = 0; Q < (n + 1) / 2; Q++) {
    if (q.empty()) break;
    long long int r = q.front();
    vst.insert(r);
    cout << "? " << r << "\n";
    cout.flush();
    vector<long long int> dist(n + 1);
    for (long long int i = 1; i < n + 1; i++) cin >> dist[i];
    map<long long int, vector<long long int>> cnt;
    for (long long int i = 1; i < n + 1; i++) cnt[dist[i]].push_back(i);
    long long int maxi = *max_element((dist).begin(), (dist).end());
    for (long long int i = 0; i < maxi + 1; i++) {
      if ((long long int)cnt[i].size() == 1) {
        if (i + 1 <= maxi) {
          for (auto it : cnt[i + 1]) {
            v[cnt[i][0]].insert(it);
          }
        }
      }
      if (i <= 1) continue;
      for (auto it : cnt[i]) {
        if (vst.find(it) == vst.end()) q.push(it);
      }
    }
    q.pop();
  }
  set<ii> ans;
  for (long long int i = 1; i < n + 1; i++) {
    for (auto it : v[i]) {
      if (ans.find(make_pair(i, it)) == ans.end() &&
          ans.find(make_pair(it, i)) == ans.end()) {
        ans.insert(make_pair(i, it));
      }
    }
  }
  cout << "!\n";
  cout.flush();
  for (auto it : ans) {
    cout << it.first << " " << it.second << "\n";
    cout.flush();
  }
  time();
  return 0;
}
