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;
long long int dx[] = {1, -1, 0, 0};
long long int dy[] = {0, 0, -1, 1};
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int power_mod(long long int a, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1)
      res = ((res % 1000000007) * (a % 1000000007)) % 1000000007, n--;
    else
      a = ((a % 1000000007) * (a % 1000000007)) % 1000000007, n /= 2;
  }
  return res;
}
long long int nCr(long long int n, long long int r) {
  if (r > n) return 0;
  double res = 1;
  for (long long int i = 1; i <= r; i++) res = (res * (n - r + i)) / i;
  return (long long int)(res + 0.01);
}
long long int power(long long int a, long long int n) {
  long long int res = 1;
  for (long long int i = 0; i < n; i++) res = res * a;
  return res;
}
bool is_palindrome(string s) {
  long long int n = s.size();
  for (long long int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) return false;
  }
  return true;
}
bool cmp(string a, string b) {
  if (a.size() < b.size())
    return true;
  else if (a.size() == b.size())
    return a < b;
  else
    return false;
}
vector<long long int> gr[500005];
long long int vis[500005];
void dfs(long long int node) {
  vis[node] = 1;
  for (long long int child : gr[node]) {
    if (vis[child] == 0) {
      dfs(child);
    }
  }
}
void solve() {
  long long int n;
  cin >> n;
  long long int cnt = 0;
  vector<pair<long long int, long long int>> edges;
  queue<long long int> q;
  q.push(1);
  set<long long int> s;
  while (cnt < n - 1) {
    long long int x = q.front();
    q.pop();
    s.insert(x);
    cout << "? " << x << endl;
    long long int dis[n + 1];
    vector<long long int> one, two;
    for (long long int i = 1; i <= n; i++) {
      cin >> dis[i];
      if (dis[i] == 1) {
        if (s.find(i) == s.end()) one.push_back(i);
      } else if (dis[i] == 2) {
        if (s.find(i) == s.end()) two.push_back(i);
      }
    }
    for (long long int i = 0; i < one.size(); i++) {
      cnt++;
      edges.push_back({x, one[i]});
    }
    if (two.size() > 0) {
      if (one.size() < two.size()) {
        for (long long int p : one) q.push(p);
      } else {
        for (long long int p : two) q.push(p);
      }
    }
  }
  cout << "!" << endl;
  for (long long int i = 0; i < edges.size(); i++) {
    cout << edges[i].first << " " << edges[i].second << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
