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 long long INF_LL = 4e18;
const int INF = 1e9 + 100;
const int MOD = 1e9 + 7;
const long double EPS = 1e-10;
const int BLOCK = 550;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
void open_file() {}
const int maxN = 3e5 + 100;
void sol() {
  int n;
  cin >> n;
  vector<vector<int> > edge(n, vector<int>(n, 0));
  vector<int> used(n, 0);
  auto ask = [&](int u) {
    cout << "? " << u + 1 << endl;
    vector<int> d(n);
    for (int i = 0; i < n; i++) cin >> d[i];
    for (int i = 0; i < n; i++) {
      if (d[i] == 1) {
        edge[u][i] = 1;
        edge[i][u] = 1;
      }
    }
    return d;
  };
  vector<int> d = ask(0);
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    if (d[i] & 1)
      a.push_back(i);
    else
      b.push_back(i);
  }
  if ((int)a.size() > (int)b.size()) swap(a, b);
  for (int u : a) ask(u);
  cout << "!" << endl;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (edge[i][j] == 1) {
        cout << i + 1 << " " << j + 1 << endl;
      }
    }
  }
}
void solve() {
  clock_t begin = clock();
  int T;
  T = 1;
  int TestCase = 0;
  while (T--) {
    TestCase += 1;
    sol();
  }
  clock_t end = clock();
  cerr << "Time: " << fixed << setprecision(10)
       << (double)(end - begin) / (double)CLOCKS_PER_SEC << '\n';
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  open_file();
  solve();
}
