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 <algorithm>
#include <vector>
#include <queue>
#include <array>
#include <stack>
#include <map>
#include <set>
using namespace std;
const int INF = 1000000000;
int n;
set<pair<int,int>> edges;
vector<int> query(int u){
    cout << "? " << u + 1 << endl;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        if(v[i] == 1){
            edges.insert({min(i, u), max(i, u)});
        }
    }
    return v;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int odd = 0;
    int even = 0;
    vector<int> orig = query(0);
    for(int i = 0; i < n; i++){
        if(orig[i] % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }
    for(int i = 1; i < n; i++){
        if(odd >= even){
            if(orig[i] % 2 == 0){
                query(i);
            }
        }else{
            if(orig[i] % 2 == 1){
                query(i);
            }
        }
    }
    cout << endl;
    cout << "!" << endl;
    cout.flush();
    for(auto it = edges.begin(); it != edges.end(); it++){
        pair<int,int> p = *it;
        cout << p.first + 1 << " " << p.second + 1 << endl;
        cout.flush();
    }
}