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>
#pragma GCC optimize("O3")
const double PI = acos(-1.0);
using namespace std;
const double EPS = 1e-9;
const int N = 500009, M = 200009;
int n, d[2009], x[2009];
set<pair<int, int>> e;
void ask(int u) {
  cout << "? " << u << endl;
  cout.flush();
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    if (x[i] == 1) e.insert({min(u, i), max(u, i)});
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  cout << "? 1" << endl;
  cout.flush();
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == 1) e.insert({1, i});
  }
  for (int i = 2; i <= n; i++) {
    if (d[i] % 2 == 0) {
      ask(i);
    }
  }
  cout << "!\n";
  for (auto p : e) {
    cout << p.first << " " << p.second << endl;
  }
  cout.flush();
  return 0;
}
