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 int N = 2007;
int n;
int maxLev;
int curLev[N];
vector<int> nodes[N];
int s[2];
void ask(int r) {
  cout << "? " << r + 1 << '\n';
  cout.flush();
}
void readLev() {
  for (int i = 0; i < n; i++) {
    cin >> curLev[i];
  }
}
int main() {
  cin >> n;
  ask(0);
  readLev();
  for (int i = 0; i < n; i++) {
    maxLev = max(maxLev, curLev[i]);
    nodes[curLev[i]].push_back(i);
    s[curLev[i] & 1]++;
  }
  int start = s[0] <= s[1] ? 0 : 1;
  vector<pair<int, int>> sol;
  for (int lev = start; lev <= maxLev; lev += 2) {
    for (int u : nodes[lev]) {
      ask(u);
      readLev();
      for (int i = 0; i < n; i++) {
        if (curLev[i] == 1) {
          sol.push_back({u + 1, i + 1});
        }
      }
    }
  }
  cout << "!" << '\n';
  for (auto e : sol) {
    cout << e.first << " " << e.second << '\n';
  }
  cout.flush();
  return 0;
}
