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 INF = 100000001;
const double EPS = 10e-9;
void solve() {
  int n;
  cin >> n;
  vector<vector<int>> G(n + 1);
  vector<vector<int>> D(n + 1, vector<int>(n + 1, -1));
  set<int> s;
  for (int i = 2; i <= (n); ++i) s.insert(i);
  cout << 1 << endl;
  for (int i = 1; i <= (n); ++i) {
    cin >> D[1][i];
    D[i][1] = D[1][i];
    if (D[1][i] == 1) {
      G[1].push_back(i);
      G[i].push_back(1);
    }
  }
  for (int i = 2; i <= (n); ++i) {
    if (D[1][i] % 2 == 1) {
      if (s.find(i) == s.end()) continue;
      s.erase(s.find(i));
    }
  }
  while (!s.empty()) {
    auto uit = s.begin();
    s.erase(uit);
    int u = *uit;
    cout << u << endl;
    for (int i = 1; i <= (n); ++i) {
      cin >> D[u][i];
      D[i][u] = D[u][i];
      if (D[u][i] == 1) {
        G[u].push_back(i);
        G[i].push_back(u);
      }
    }
  }
  set<pair<int, int>> es;
  for (int i = 1; i <= (n); ++i) {
    for (int j = 0; j < ((int)(G[i]).size()); ++j) {
      es.insert(make_pair(min(i, G[i][j]), max(i, G[i][j])));
    }
  }
  cout << "!\n";
  for (auto p : es) {
    cout << p.first << " " << p.second << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
}
