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;
  vector<int> l;
  vector<int> r;
  vector<int> d[n];
  cout << "? 1" << endl;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp == 1) {
      l.push_back(0);
      r.push_back(i);
    }
    d[tmp].push_back(i);
  }
  int o1 = 0;
  for (int i = 1; i < n; i += 2) o1 += ((int)d[i].size());
  int o2 = 0;
  for (int i = 2; i < n; i += 2) o2 += ((int)d[i].size());
  if (o1 < o2)
    for (int i = 1; i < n; i += 2)
      for (int j : d[i]) {
        cout << "? " << j + 1 << endl;
        for (int k = 0; k < n; k++) {
          int tmp;
          cin >> tmp;
          if (tmp == 1) {
            l.push_back(j);
            r.push_back(k);
          }
        }
      }
  else
    for (int i = 2; i < n; i += 2)
      for (int j : d[i]) {
        cout << "? " << j + 1 << endl;
        for (int k = 0; k < n; k++) {
          int tmp;
          cin >> tmp;
          if (tmp == 1) {
            l.push_back(j);
            r.push_back(k);
          }
        }
      }
  cout << '!' << endl;
  for (int i = 0; i < (n - 1); i++) cout << l[i] + 1 << ' ' << r[i] + 1 << endl;
  return 0;
}
