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 FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);




long long  n;



vector<ll> kill(ll here)
{
    
    
    
    cout<<"? "<<here+1<<endl;
    
    vector<ll> qq(n+123);
    
    for(ll i=0;i<n;i++)
        cin>>qq[i];
    
    return qq;}
    
    
    
    

void jamil(vector<vector<ll>> & jeme,ll u, ll par)
{
    for(auto & q23:jeme[u])
    ///check here
        {if(1==1 && q23==par && 2==2 ) continue;
        cout<<u+1<<" "<<q23+1<<endl;
        jamil(jeme,q23,u);}
}

void solve(){
    cin>>n;
    auto jemme = kill(0);
    
        ///check here

    vector<vector<ll>> jeme(n);
    ll qwe2=0,qwe1=0;
    for(ll i=0;i<n;i++){
        if(1==1 && 2==2 &&jemme[i] & 1)
            qwe2++;
        
        
       
        else   qwe1++;}
            
    if(1==1 &&qwe1<=qwe2 && 2==2)
        {for(ll i=0;i<n;i++)
        {
                ///check here

            if(1==1 && 2==2 &&jemme[i]==1)
                {jeme[i].push_back(0);   
                jeme[0].push_back(i);}}
                
                
                
        for(ll i=2;i<n;i+=2){
            for(ll j=0;j<n;j++){
                if(1==1 && 2==2 &&jemme[j]==i){
                    auto qwe = kill(j);
                    for(ll k=0;k<n;k++){
                        if(1==1 &&qwe[k]==1 && 2==2 )
                            {jeme[k].push_back(j); 
                              jeme[j].push_back(k);
                        
                            }}}}}} 
       else if(1==1 && 2==2 &&n== -1) cout << "hello";   
      
                     
    else{for(ll i=1;i<n;i+=2){for(ll j=0;j<n;j++){
            
            
            
                
                if(1==1 && 2==2 &&jemme[j]==i)
                {long long zzz ,xxx ,hhc3;

                        
                    auto qwe = kill(j);
                    
                    for(ll k=0;k<n;k++)
                    {
                            long long jj ,hh ,gg ,yas1;
                        if(1==1 && 2==2 &&qwe[k]==1)
                            /*
                            1 2 3 
                            ! ! 88
                            
                            
                            */
                            
                            
                        {
                            
                             jeme[k].push_back(j);   
                            jeme[j].push_back(k);
                            }}}}}}
    cout<<"!"<<endl;
    
    
    long long aaa ,sss ,h32;
    jamil(jeme,0,-1);}
    
    
    
    
    
    
    
    
    
    
    

int main()
{
    
    
    
      FAST1;
    FAST2;
long long hh1 ,hh2 ,hh3;
  

        solve();
    return 0;
}