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 pi = acos(-1.0);
void setIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
vector<int> adj[2005];
vector<int> arr[2005];
int vis[2005]{0};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 1; i <= (n + 1) / 2; i++) {
    int idx;
    for (int j = 1; j <= n; j++) {
      if (vis[j] == 0) {
        idx = j;
        break;
      }
    }
    cout << "? " << idx << "\n";
    cout << flush;
    int x[n + 1];
    for (int j = 1; j <= n; j++) {
      cin >> x[j];
      if (x[j] == 1 || x[j] == 0) {
        vis[j] = 1;
      }
      if (x[j] == 1) {
        v.push_back({idx, j});
      }
    }
    for (int j = 1; j <= n; j++) {
      arr[idx].push_back(x[j]);
    }
  }
  int id = -1;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      id = i;
    }
  }
  if (id != -1) {
    int g = 0;
    for (int i = 1; i <= n; i++) {
      if (g == 1) break;
      if (arr[i].size() == 0) continue;
      for (int j = 1; j <= n; j++) {
        if (j != i && arr[i][j - 1] == 1 && arr[i][id - 1] == 2) {
          g = 1;
          v.push_back({j, id});
          break;
        }
      }
    }
  }
  cout << "! "
       << "\n";
  cout << flush;
  for (auto x : v) {
    cout << x.first << " " << x.second << "\n";
    cout << flush;
  }
  return 0;
}
