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>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}

vector<int> graph[17];
vector<int> dist(16);

void dfs(int at,int p,int h){
    dist[at-1]=h;
    for(int &i:graph[at]){
        if(i==p)
            continue;
        dfs(i,at,h+1);
    }
}

int n;

vector<int> ask(int x){
    cout<<"? "<<x<<endl;
    #ifdef LOCAL
    dfs(x,-1,0);
    for(int &i:dist)
        cout<<i<<" ";
    cout<<"\n";
    return dist;
    #endif
    vector<int> a(n);
    for(int &i:a)
        cin>>i;
    return a;
}

void solve(){
    cin>>n;
    vector<pii> ans;
    vector<int> a=ask(1);
    int cnt[2]={0,0};
    for(int i=0;i<n;i++){
        cnt[a[i]&1]++;
        if(a[i]==1)
            ans.pb({1,i+1});
    }
    int best=cnt[0]<=cnt[1]?0:1;
    for(int i=1;i<n;i++){
        if((a[i]&1)==best){
            vector<int> v=ask(i+1);
            for(int j=1;j<n;j++){
                if(v[j]==1){
                    ans.pb({i+1,j+1});
                }
            }
        }
    }
    assert(sz(ans)==n-1);
    cout<<"!"<<endl;
    for(pii &i:ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    #ifdef LOCAL
    for(int i=0;i<1;i++){
        int a,b; cin>>a>>b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}