#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second

typedef long long ll;
typedef pair<int, int> pi;

int n;

void query(int r, vector<int> &ans){
    cout << "? " << r << endl;
    for(int i = 1; i <= n; i++) cin >> ans[i];
}


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<int> par(n+1);
    vector<int> dist1(n+1), distcur(n+1);
    query(1,dist1);
    vector<pi> dist2;
    par[1] = -1;
    for(int i = 1; i <= n; i++){
        if(dist1[i] == 1)
            par[i] = 1;
        if(par[i] == 0) dist2.push_back({dist1[i], i});
    }
    sort(dist2.begin(), dist2.end(), greater<pi>());
    for(auto &a: dist2){
        if(par[a.s] != 0) continue;
        int cur = a.s;
        query(cur, distcur);
        vector<int> branch(dist1[cur]+1);
        for(int i = 1; i <= n; i++){
            if(dist1[i]+distcur[i] == dist1[cur]) branch[dist1[i]] = i;
        }
        for(int i = 2; i <= n; i++){
            if(dist1[i]+distcur[i] == dist1[cur]){
                par[i] = branch[dist1[i]-1];
            }else if(dist1[i]+distcur[i] == dist1[cur]+2){
                par[i] = branch[dist1[i]-1];
            }
        }
    }
    cout << "!" << "\n";
    for(int i = 2; i <= n; i++) cout << par[i] << " " << i << "\n";
    cout.flush();
    return 0;
}
