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 namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  int vis[n + 1];
  memset(vis, 0, sizeof vis);
  vector<pair<int, int> > adj;
  for (int i = 0; i < n; ++i) {
    if (vis[i + 1]) continue;
    vis[i + 1] = 1;
    cout << "? " << i + 1 << endl;
    vector<int> s;
    int freq[n + 1];
    memset(freq, 0, sizeof freq);
    for (int j = 1; j <= n; ++j) {
      int a;
      cin >> a;
      freq[a]++;
      s.push_back(a);
    }
    for (int j = 0; j < n; ++j) {
      if (s[j] == 1) {
        vis[j + 1] = 1;
        adj.push_back({i + 1, j + 1});
      } else {
        bool p = true;
        for (int k = 0; k < s[j] && p; ++k) {
          if (freq[k] > 1) p = false;
        }
        if (p && !vis[j + 1]) {
          vis[j + 1] = 1;
          int ind = 0;
          for (int k = 0; k < n; ++k) {
            if (s[k] == s[j] - 1) adj.push_back({k + 1, j + 1});
          }
        }
      }
    }
  }
  cout << '!' << endl;
  for (auto x : adj) {
    cout << x.first << " " << x.second << endl;
  }
}
