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 pb emplace_back
#define mp make_pair
#define fs first
#define sn second
#define cor(x) (((x%mod)+mod)%mod)
 
typedef int64_t ll;
 
template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;}  
template<typename T, typename U> static inline void amax(T &x, U y){if (x < y)x = y;} 
 
//void precomp(){}
 
void solve(){
    set<pair<int,int> > s;
    int n;cin>>n;

    int L=n/2;if(n&1)L++;
    int d[n];int c=0;
    cout<<"? 1"<<endl;//fflush(stdout); 
    for(int i=0;i<n;i++){
        cin>>d[i];
        if(d[i]&1)c++;
        if(d[i]==1)s.insert(mp(min(0,i),max(0,i)));
    }

    if(s.size()==n-1){
        cout<<"!\n";
        for(auto i: s){
            cout<<i.fs+1<<" "<<i.sn+1<<endl;
        }
        //fflush(stdout);
        return;
    }

    int dt[n];
    if(c<n-1-c){
        for(int i=0;i<n;i++){
            if(d[i]&1){
                cout<<"? "<<i+1<<endl;//fflush(stdout);
                L--;
                if(L==0)return;
                for(int j=0;j<n;j++){
                    cin>>dt[j];
                    if(dt[j]==1)s.insert(mp(min(i,j),max(i,j)));
                }
            }
        }
    }

    else {
        for(int i=1;i<n;i++){
            if(!(d[i]&1)){
                cout<<"? "<<i+1<<endl;//fflush(stdout);
                L--;
                if(L==0)return;
                for(int j=0;j<n;j++){
                    cin>>dt[j];
                    if(dt[j]==1)s.insert(mp(min(i,j),max(i,j)));
                }
            }
        }
    }

    if(s.size()==n-1){
        cout<<"!\n";
        for(auto i: s){
            cout<<i.fs+1<<" "<<i.sn+1<<endl;
        }
        //fflush(stdout);
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    //precomp();
    //int tc;cin>>tc;while(tc--)
    solve();
    
    return 0;
}