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;

void q(int r){
    cout << "? " << r << "\n";
    cout.flush();
}

vector<int> dist[2100];

int arr[2100];

set<pair<int, int> > S;

int main(){
    int N; cin >> N;
    q(1);
    for (int i = 1; i <= N; i++){
        cin >> arr[i];
        dist[arr[i]].push_back(i);
        if (arr[i] == 1){
            S.insert(make_pair(1, i));
        }
    }
    int oddsum = 0;
    int evensum = 0;
    for (int i = 1; i <= N; i++){
        if (i%2 == 1) oddsum += dist[i].size();
        else evensum += dist[i].size();
    }
    int st = 0;
    if (oddsum > evensum) st = 2;
    else st = 1;
    for (int i = st; i <= N; i += 2){
        for (int j = 0; j < dist[i].size(); j++){
            q(dist[i][j]);
            for (int k = 1; k <= N; k++){
                cin >> arr[k];
                if (arr[k] == 1){
                    S.insert(make_pair(min(dist[i][j], k), max(dist[i][j], k)));
                }
            }
        }
    }
    cout << "!\n";
    for (pair<int, int> p : S){
        cout << p.first << " " << p.second << "\n";
    }
}