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;
const double eps = 1e-8;
long long ii = 1;
void solve() {
  long long n;
  cin >> n;
  set<pair<long long, long long>> st;
  queue<long long> q;
  q.push(1);
  long long cn = 0;
  bool clr[n + 2];
  memset(clr, true, sizeof(clr));
  clr[1] = false;
  while (!(q.empty())) {
    cn++;
    long long pre = q.front();
    q.pop();
    cout << "? " << pre << endl;
    long long a[n + 1];
    map<long long, vector<long long>> m;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      if (clr[i + 1] == true) m[a[i]].push_back(i + 1);
    }
    for (long long i = 1;; i++) {
      if (m[i].size() == 0) break;
      if (m[i].size() == 1) {
        long long p1 = pre;
        long long p2 = m[i][0];
        if (p1 > p2) swap(p1, p2);
        st.insert({p1, p2});
        pre = m[i][0];
      } else {
        for (long long j = 0; j < m[i].size(); j++) {
          long long p2 = m[i][j];
          long long p1 = pre;
          if (clr[p2] == true) q.push(p2);
          clr[p2] = false;
          if (p1 > p2) swap(p1, p2);
          st.insert({p1, p2});
        }
        break;
      }
    }
    if (st.size() == n - 1) break;
  }
  cout << "!" << '\n';
  for (auto it = st.begin(); it != st.end(); it++) {
    pair<long long, long long> pair<long long, long long> = *it;
    cout << pair<long long, long long>.first << ' '
         << pair<long long, long long>.second << '\n';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long TestCase;
  TestCase = 1;
  while (TestCase--) solve();
  return 0;
}
