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;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
void printarr(long long a[], long long n) {
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
}
void scanarr(long long a[], long long n) {
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
}
void testcase() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v[n + 1];
  vector<long long> tree[n + 1];
  long long query = ceil(n / 2.0);
  long long root = 1;
  queue<long long> q;
  q.push(root);
  long long cnt = 0;
  vector<bool> vis2(n + 2, false);
  vis2[root] = true;
  while (!q.empty()) {
    if (cnt == query) break;
    cnt++;
    map<long long, vector<long long> > mp;
    cout << "? " << root << endl;
    long long d;
    for (int j = 1; j <= n; j++) {
      cin >> d;
      mp[d].push_back(j);
    }
    long long i = -1;
    for (auto it : mp) {
      i++;
      if (i == 0) continue;
      if (mp[i - 1].size() > 1) break;
      for (auto nodes : it.second) {
        tree[root].push_back(nodes);
      }
      if (tree[root].size() == 1)
        root = tree[root][0];
      else
        break;
    }
    i = 0;
    for (auto it : mp) {
      if ((i % 2 == 0)) {
        for (auto it2 : it.second) {
          q.push(it2);
          vis2[it2] = true;
        }
      }
      i++;
    }
  }
  bool vis[n + 1][n + 1];
  memset(vis, false, sizeof(vis));
  cout << "!" << endl;
  for (long long i = 1; i <= n; i++) {
    if (tree[i].size() == 0) continue;
    for (auto j : tree[i]) {
      if (!vis[i][j]) {
        cout << i << " " << j << endl;
        vis[i][j] = true;
        vis[j][i] = true;
      }
    }
  }
  return;
}
int main() {
  long long tc = 1;
  for (long long i = 1; i <= tc; i++) {
    testcase();
  }
  return 0;
}
