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;
typedef long long int ll;
#define mod 1000000007
ll dmod(ll x){
    return ((x+mod)%mod);
}
ll modular_power(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1)ans=dmod(ans*x);
        y/=2;
        x=dmod(x*x);
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    cout<<"? 1"<<endl;
    int arr[n+1][n+1];
    int mx=0;
    for(int i=1;i<=n;i++)cin>>arr[1][i];
    set <int> odd,even;
    int par[n+1];
    for(int i=1;i<=n;i++)if(arr[1][i]==1)par[i]=1;
    for(int i=2;i<=n;i++){
        if(arr[1][i]&1)odd.insert(i);
        else even.insert(i);
    }
    int arr2[n+1];
    if(odd.size()<=even.size()){
        while(!odd.empty()){
            auto it=*(odd.begin());
            cout<<"? "<<it<<endl;
            odd.erase(it);
            for(int i=1;i<=n;i++){
                cin>>arr2[i];
                if(arr2[i]==1 && arr[1][i]>arr[1][it])par[i]=it;
                else if(arr2[i]==1 && arr[1][i]<arr[1][it])par[it]=i;
            }
        }
    }
    else {
        while(!even.empty()){
            auto it=*(even.begin());
            cout<<"? "<<it<<endl;
            even.erase(it);
            for(int i=1;i<=n;i++){
                cin>>arr2[i];
                if(arr2[i]==1 && arr[1][i]>arr[1][it])par[i]=it;
                else if(arr2[i]==1 && arr[1][i]<arr[1][it])par[it]=i;
            }
        }
    }
    cout<<"!"<<endl;
    for(int i=2;i<=n;i++)cout<<i<<" "<<par[i]<<endl;
    return 0;
}