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>
const long long int inf = 1e9 + 7;
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << "? " << 1 << endl;
  cout.flush();
  vector<int> v;
  int odd = 0;
  int even = 0;
  set<pair<int, int>> s;
  for (int i = 1; i <= n; i++) {
    int c;
    cin >> c;
    v.push_back(c);
    if (c == 1) {
      s.insert({1, i});
    }
    if (c % 2 == 0 && c != 0) {
      even++;
    } else if (c % 2 != 0) {
      odd++;
    }
  }
  vector<int> ans;
  if (even > odd) {
    for (int i = 0; i < n; i++) {
      if (v[i] % 2 != 0) {
        ans.push_back(i + 1);
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (v[i] % 2 == 0) {
        ans.push_back(i + 1);
      }
    }
  }
  int x = ans.size();
  for (int i = 0; i < x; i++) {
    cout << "? " << ans[i] << endl;
    cout.flush();
    for (int j = 1; j <= n; j++) {
      int c;
      cin >> c;
      if (c == 1 && j > ans[i]) {
        s.insert({ans[i], j});
      } else if (c == 1 && j <= ans[i]) {
        s.insert({j, ans[i]});
      }
    }
  }
  int z1 = s.size();
  cout << "!" << endl;
  for (auto itr = s.begin(); itr != s.end(); itr++) {
    pair<int, int> p = *itr;
    cout << p.first << " " << p.second << endl;
  }
  cout.flush();
}
