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;
#define ll long long
#define N 200100
#define mod 1000000007
#pragma comment(linker, '/stack:200000000')
#define ii pair<int,int>
void solve(){
    int n;cin>>n;
    vector<ii> edges;

    cout<<"? 1"<<'\n';
    int dist[n+1],odd=0;
    vector<bool> vis(n+1,false);

    for(int i=1;i<=n;i++){
        cin>>dist[i];
        if(dist[i]%2) odd++;
        if(dist[i]==1)  edges.push_back({1,i});
    }
    cout.flush();
    vis[1]=true;

    if(odd < (n+1)/2){

        for(int i=2;i<=n;i++){
            if(dist[i]%2){
                cout << "? " << i << '\n';

                for(int j=1;j<=n;j++){
                    int x;cin>>x;
                    if(!vis[j] and x==1)    edges.push_back({i,j});
                }

                vis[i]=true;
                cout.flush();
            }
        }
    }
    else{

        for(int i=2;i<=n;i++){
            if(dist[i]%2==0){
                cout << "? " << i << '\n';

                for(int j=1;j<=n;j++){
                    int x;cin>>x;
                    if(!vis[j] and x==1)    edges.push_back({i,j});
                }

                vis[i]=true;
                cout.flush();
            }
        }
    }

    cout<<"!\n";
    for(auto v:edges)   cout<<v.first<<' '<<v.second<<'\n';
}

signed main(){
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //int t;cin>>t;while(t--)
        solve();
}