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 <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>
#include <chrono>
 
using namespace std;
 
typedef long long ll;
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  auto ask = [&] (int v) {
    cout << "? " << v + 1 << endl;
    vector <int> d(n);
    for (int i = 0; i < n; ++i) cin >> d[i];
    return d;
  };
  vector <int> c(n);
  vector <int> cnt(2);
  auto st = ask(0);
  for (int i = 0; i < n; ++i) {
    c[i] = st[i] % 2;
    ++cnt[c[i]];
  }
  int cl = -1;
  if (cnt[0] <= cnt[1]) {
    cl = 0;
  } else {
    cl = 1;
  }
  vector <pair <int, int>> ans;
  for (int i = 0; i < n; ++i) {
    if (c[i] == cl) {
      vector <int> d;
      if (i == 0) d = st;
      else d = ask(i);
      for (int j = 0; j < n; ++j) {
        if (d[j] == 1) {
          ans.push_back({i, j});
        }
      }
    }
  }
  cout << "!" << endl;
  for (auto p : ans) {
    cout << p.first + 1 << ' ' << p.second + 1 << endl;
  }
}

