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;
using ll = long long;

void solve(){
    int n = 0;
    cin>>n;

    vector<vector<int>> v(n);
    //vector<set<int>> s(n);
    vector<int> q;
    set<int> st;
    q.push_back(1);
    while(!q.empty()){
        vector<int> t;

        for(int j : q){
            st.insert(j);
            cout<<"? "<<j<<endl;
            
            vector<int> d(n);
            int x1 = 0, x2 = 0, x3 = 0;
            for(int i = 0; i < n; ++i){
                int x;
                cin>>x; d[i] = x;
                if(x == 1) v[j-1].push_back(i);

                if(x % 2 && !st.count(i+1)) ++x1;
                if(x % 2 == 0 && !st.count(i+1)) ++x2;
            } 

            for(int i = 0; i < n; ++i){
                if(x1 < x2) {
                    if(d[i]%2  && !st.count(i+1))
                    t.push_back(i+1);
                }
                if(x1 >= x2) {
                    if(d[i]%2 == 0  && !st.count(i+1))
                    t.push_back(i+1); 
                }
                st.insert(i+1); 
            }
        }
        q = t;
    }

    cout<<"!"<<endl;
    set<pair<int,int>> kt;
    for(int i = 0; i < n; ++i){
        for(int j : v[i]) {
            int mn = min(i+1, j+1), mx = max(i+1, j+1);
            if(!kt.count({mn, mx}))
            kt.insert({mn,mx}), cout<<i+1<<" "<<j+1<<endl;
        }
    }
    return;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    //cin>>t;
    while(t--) solve();

    return 0;
}