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;
vector<long long int> adj[100001];
long long int visit[100001];
int main() {
  {
    long long int n;
    cin >> n;
    queue<long long int> q;
    q.push(1);
    long long int cnt = 0;
    visit[1] = 1;
    while (q.size()) {
      int curr = q.front();
      q.pop();
      cout << "? " << curr << endl;
      long long int a[n];
      for (int i = 0; i < n; i++) cin >> a[i];
      long long int c = 1, node = curr, find = 1;
      while (c == 1) {
        c = 0;
        curr = node;
        for (int i = 0; i < n; i++) {
          if (a[i] == find && visit[i + 1] == 0) {
            node = i + 1;
            c++;
            cnt++;
            visit[i + 1] = 1;
            adj[i + 1].push_back(curr);
            q.push(i + 1);
          }
        }
        find++;
      }
      if (cnt == n - 1) break;
    }
    cout << "!\n";
    for (int i = 1; i < n + 1; i++) {
      for (auto it : adj[i]) cout << i << " " << it << endl;
    }
  }
  return 0;
}
