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;
int INF = 1000000007;
long long INFLL = (long long)INF * (long long)INF;
long double EPS = 10e-9;
long double pi = 2 * acos(0.0);
int n;
set<int> s;
void ask(int i, vector<long long> &v) {
  cout << "? " << i << endl;
  for (int j = 0; j < n; ++j) {
    int x;
    cin >> x;
    v.push_back(x);
  }
}
void solve() {
  cin >> n;
  vector<long long> v;
  ask(1, v);
  for (int i = 2; i < n + 1; i++) s.insert(i);
  vector<pair<long long, long long> > output;
  set<pair<long long, long long> > nodes;
  set<pair<long long, long long> > ulta_nodes;
  for (int i = 0; i < n; ++i) {
    if (v[i] == 1) {
      output.push_back(make_pair(1, i + 1));
      nodes.insert(make_pair(v[i], i + 1));
      ulta_nodes.insert(make_pair(i + 1, v[i]));
      s.erase(i + 1);
    } else if (v[i] > 1) {
      nodes.insert(make_pair(v[i], i + 1));
      ulta_nodes.insert(make_pair(i + 1, v[i]));
    }
  }
  while (s.size() > 0) {
    if (nodes.size() == 1) {
      auto temp = *nodes.begin();
      v.clear();
      ask(temp.second, v);
      s.erase(temp.second);
      nodes.erase(temp);
      for (int i = 0; i < n; ++i) {
        if (v[i] == 1) {
          output.push_back(make_pair(i + 1, temp.second));
          s.erase(i + 1);
          auto it = ulta_nodes.lower_bound(make_pair(i + 1, 0));
          if (it != ulta_nodes.end()) {
            auto paar = *it;
            if (paar.first != i + 1) continue;
            nodes.erase(make_pair(paar.second, paar.first));
          }
        }
      }
    } else if (nodes.size() > 1) {
      auto nd = nodes.end();
      nd--;
      auto hehe = *nd;
      auto temp = *nodes.begin();
      auto it = nodes.lower_bound(make_pair(temp.first + 1, 0));
      if (it == nodes.end()) it--;
      temp = *it;
      if (temp.first == hehe.first) temp = *nodes.begin();
      v.clear();
      ask(temp.second, v);
      s.erase(temp.second);
      nodes.erase(temp);
      for (int i = 0; i < n; ++i) {
        if (v[i] == 1) {
          output.push_back(make_pair(i + 1, temp.second));
          s.erase(i + 1);
          auto it = ulta_nodes.lower_bound(make_pair(i + 1, 0));
          if (it != ulta_nodes.end()) {
            auto paar = *it;
            if (paar.first != i + 1) continue;
            nodes.erase(make_pair(paar.second, paar.first));
          }
        }
      }
    } else {
      break;
    }
  }
  cout << "! ";
  for (auto ash : output) {
    cout << ash.first << " " << ash.second << " ";
  }
  cout << endl;
}
int32_t main() {
  clock_t start, end;
  start = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  end = clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
  cerr << "\nTime taken by program is : " << fixed << time_taken
       << setprecision(5);
  cerr << " sec " << endl;
  return 0;
}
