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;
using ll = long long;
int n, m, k, q;
const int INF = 1e9 + 5;
const int maxn = 4e5 + 5;
const ll mod = 1e9 + 7;
int dis[2005];
int main() {
  cin >> n;
  for (int i = 0; i < 2005; ++i) dis[i] = 0;
  queue<int> q;
  q.push(1);
  set<int> s;
  s.insert(1);
  vector<bool> visited(n + 1, false);
  vector<vector<int>> g(n + 1);
  visited[1] = true;
  auto &&ask = [&](int u) {
    cout << "? " << u << endl;
    for (int i = 1; i <= n; ++i) cin >> dis[i];
    int ma = *max_element(dis, dis + n + 1);
    if (ma == 2) {
      for (int i = 1; i <= n; ++i) {
        if (dis[i] == 1 && !visited[i]) {
          g[u].push_back(i);
          q.push(i);
          visited[i] = 1;
        }
      }
      return;
    }
    bool added = false;
    for (int i = 1; i <= n; ++i) {
      if (dis[i] == 2 && !visited[i]) {
        q.push(i);
        visited[i] = 1;
      }
      if (dis[i] == 1) {
        g[u].push_back(i);
      }
    }
  };
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    ask(v);
  }
  cout << "! ";
  for (int i = 1; i <= n; ++i) {
    for (auto j : g[i]) {
      cout << i << " " << j << endl;
    }
  }
  return 0;
}
