#include <bits/stdc++.h>

using namespace std;

const int N = 2e3 + 5;

int n, arr[N];

bool graph[N][N];

vector<int> even, odd;

int main(){
    cin >> n;
    
    cout << "? " << 1 << "\n";
    cout.flush();

    for(int i = 1; i <= n; i++) cin >> arr[i];

    for(int i = 1; i <= n; i++){
        if(i != 1 && arr[i] % 2 == 0) even.push_back(i);
        else if(i != 1 && arr[i] % 2 == 1) odd.push_back(i);

        if(arr[i] == 1){
            graph[1][i] = true;
            graph[i][1] = true;
        }
    }

    if(odd.size() < even.size()) swap(odd, even);

    for(auto v : even){

        cout << "? " << v << "\n";
        cout.flush();

        for(int i = 1; i <= n; i++) cin >> arr[i];

        for(int i = 1; i <= n; i++){
            if(arr[i] == 1){
                graph[v][i] = true;
                graph[i][v] = true;
            }
        }
    }

    cout << "!" << "\n";
    cout.flush();

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(graph[i][j]){
                cout << i << " " << j << "\n";
                cout.flush();

                graph[j][i] = false;
            }
        }
    }
}