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 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;
            }
        }
    }
}