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;

const int mod=1000000000+7;
const int maxn=2200+5;
int n;
int a[maxn][maxn];
int vis[maxn];
typedef pair<int,int> pii;
priority_queue<pii,vector<pii>,less<pii> >q;
vector<pii> vec;
vector<pii> res;
int vv[maxn][maxn];
int pdis[maxn];

int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    cout<<"? "<<1<<"\n";
    fflush(stdout);
    for(int i=1;i<=n;i++) {
        cin>>a[1][i];
        q.push({a[1][i],i});
        if(a[1][i]==1) {
            res.push_back({1,i});
            vv[1][i]=1;vv[i][1]=1;
            vis[1]=1;
            vis[i]=1;
        }
    }
    while(q.size()){
        pii x=q.top();q.pop();
        int u=x.second;
        if(vis[u]) continue;
        cout<<"? "<<u<<"\n";
        fflush(stdout);
        for(int i=1;i<=n;i++) {
            cin>>a[u][i];
            if(a[u][i]==1&&vv[u][i]==0&&vv[i][u]==0){
                res.push_back({u,i});
                vv[u][i]=1;
                vv[i][u]=1;
                vis[i]=1;
                vis[u]=1;
            }
        }
        vec.clear();
        for(int i=1;i<=n;i++){
            if((a[1][i]+a[u][i])==a[1][u]) {
                vec.push_back({a[1][i],i});
                vis[i]=1;
                pdis[a[1][i]]=i;
            }
        }
        for(int i=1;i<=n;i++){
            if((a[1][i]+a[u][i]-a[1][u])%2==0){
                int px=(a[1][i]+a[u][i]-a[1][u])/2;
                if(px==1){
                    int pu=pdis[a[1][i]-1];
                    int pv=i;
                    if(vv[pu][pv]==0&&vv[pv][pu]==0){
                        res.push_back({pu,pv});
                        vv[pu][pv]=1;vv[pv][pu]=1;
                        vis[pu]=1;
                        vis[pv]=1;
                    }
                }
            }
        }
        sort(vec.begin(),vec.end());
        for(int i=1;i<vec.size();i++) {
            int pu=vec[i].second;
            int pv=vec[i-1].second;
            if(vv[pu][pv]||vv[pv][pu]) continue;
            res.push_back({vec[i].second,vec[i-1].second});
            vv[pu][pv]=1;vv[pv][pu]=1;
            vis[pu]=1;
            vis[pv]=1;
        }
    }
    cout<<"!\n";
    fflush(stdout);
    for(int i=0;i<res.size();i++){
        cout<<res[i].first<<" "<<" "<<res[i].second<<"\n";
        fflush(stdout);
    }
    fflush(stdout);
    return 0;
}