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 <random>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair
#define pll pair<long long,long long>
#define ld long double
#define ull unsigned long long

using namespace std;

vector<pii> ans;
int n;

vector<int> last;
int ile = 0;
void ask(int v){
    ile++;
    assert(ile <= (n + 1) / 2);
    v++;
    cout << "? " << v << endl;
    fflush(stdout);
    vector<int> ans(n, 0);
    for(int i=0;i<n;i++) cin >> ans[i];
    last = ans;
}

void solve(){
    cin >> n;
    ask(0);
    vector<int> p;
    vector<int> np;
    for(int i=0;i<n;i++){
        if(last[i]%2==0) p.pb(i);
        else np.pb(i);
    }

    if(p.size() > np.size()){
        swap(p, np);
    }

    for(int xd : p){
        if(xd != 0) ask(xd);
        for(int i=0;i<n;i++){
            if(last[i] == 1) ans.pb(mp(xd, i));
        }
    }
    cout << "!" << endl;
    fflush(stdout);
    for(pii cur : ans){
        cout << cur.st + 1 << " " << cur.nd + 1 << endl;
        fflush(stdout);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    int tt = 1;
    //cin >> tt;
    while(tt--) solve();

    return 0;
}
