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;
void err() { cout << endl; }
template <class T, class... Ts>
void err(T arg, Ts &...args) {
  cout << arg << ' ';
  err(args...);
}
const int N = 2e3 + 10;
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
long long rng(long long l, long long r) {
  uniform_int_distribution<long long> uni(l, r);
  return uni(mt);
}
int fa[N];
int dep[N];
bool vis[N];
void solve(int tCase) {
  int n;
  cin >> n;
  cout << "? 1\n";
  fflush(stdout);
  for (int i = 1; i <= n; ++i) {
    cin >> dep[i];
    fa[i] = 1;
  }
  priority_queue<pair<int, int>> q;
  for (int i = 2; i <= n; ++i) {
    if (dep[i] == 1) continue;
    q.emplace(dep[i], i);
  }
  while (!q.empty()) {
    auto pii = q.top();
    q.pop();
    int id = pii.second;
    if (vis[id]) continue;
    cout << "? " << id << '\n';
    fflush(stdout);
    vector<int> dis(n + 1);
    vector<pair<int, int>> v;
    for (int i = 1; i <= n; ++i) {
      cin >> dis[i];
      if (dis[i] == dep[id] - dep[i]) {
        v.emplace_back(dep[i], i);
        vis[i] = true;
      }
    }
    sort(v.begin(), v.end());
    for (int i = 1; i < v.size(); ++i) {
      fa[v[i].second] = v[i - 1].second;
    }
  }
  cout << "!\n";
  fflush(stdout);
  for (int i = 2; i <= n; ++i) {
    cout << fa[i] << ' ' << i << '\n';
  }
  fflush(stdout);
}
int main() {
  ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 1; t <= T; ++t) {
    solve(t);
  }
  return 0;
}
