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 <iomanip>
#include <fstream>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// constexpr int mod = 1e9 + 7;
// constexpr int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n, x;
int dist[2010][2010];

inline void work() {
    cin >> n;
    cout << "? 1" << endl;

    for (int i = 1; i <= n; ++i) {
        cin >> x;
        dist[1][i] = dist[i][1] = x;
    }

    int odd = 0, even = 0;
    for (int i = 1; i <= n; ++i) {
        if (dist[1][i] % 2 == 0) {
            ++even;
        }
        else {
            ++odd;
        }
    }
    
    int op = (even <= odd ? 0 : 1);
    for (int i = 2; i <= n; ++i) {
        if (dist[1][i] % 2 == op) {
            cout << "? " << i << endl;
            for (int j = 1; j <= n; ++j) {
                cin >> x;
                dist[i][j] = dist[j][i] = x;
            }
        }
    }

    cout << "!" << endl;
    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (dist[i][j] == 1) {
                cout << i << " " << j << endl;
            }
        }
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}