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;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Up, typename... Down>
void dbg_out(Up U, Down... D) {
  cerr << ' ' << U;
  dbg_out(D...);
}
const int N = 2010;
int n;
bool called[N];
vector<int> v[N];
map<pair<int, int>, bool> mp;
void ask(int pos) {
  called[pos] = 1;
  cout << "? " << pos << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  vector<int> dis(n + 1);
  for (int i = 1; i <= n; i++) {
    if (called[i]) continue;
    if (!called[i]) {
      ask(i);
      int cnt = 0, nd;
      for (int j = 1; j <= n; j++) {
        cin >> dis[j];
        if (dis[j] == 1) {
          cnt++;
          called[j] = 1;
          v[i].push_back(j);
          v[j].push_back(i);
          nd = j;
        }
      }
      if (cnt == 1) {
        for (int j = 1; j <= n; j++) {
          if (dis[j] == 2) {
            v[nd].push_back(j);
            v[j].push_back(nd);
            called[j] = 1;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
  }
  cout << "!" << endl;
  int k = 0;
  for (int i = 1; i <= n; i++) {
    for (auto it : v[i]) {
      if (!mp[{it, i}] && !mp[{i, it}]) {
        mp[{i, it}] = 1;
        mp[{it, i}] = 1;
        k++;
        assert(k < n);
        cout << it << " " << i << endl;
      }
    }
  }
  return 0;
}
