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>
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
// #define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define F first
#define S second
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
#define ms(a,x) memset(a, x, sizeof(a))
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;

int main()
{
    // fast;
    ll n; cin>>n;
    cout<<"? "<<1<<endl;
    ll d[n+1];
    vector<ll>o,e;
    vector<pair<ll,ll>>v;
    map<pair<ll,ll>,ll>m;

    fo(i,0,n) {
        cin>>d[i];
        if(d[i]==0) continue;
        if(d[i]%2==0)
            e.pb(i+1);
        else
            o.pb(i+1);
        if(d[i]==1){
            v.pb(mp(1ll,i+1));
            m[{i+1,1ll}]=1;
            m[{1ll,i+1}]=1;
        }
    }

    if(o.size()>e.size()) swap(o,e);
    fo(i,0,o.size()){
        cout<<"? "<<o[i]<<endl;
        fo(j,0,n) {
            cin>>d[j];
            if(d[j]==1 && !m[{o[i],j+1}]){
                v.pb(mp(o[i], j+1));
                m[{o[i], j+1}]=1;
                m[{j+1, o[i]}]=1;
            }
        }
    }
    
    cout<<"!"<<endl;
    for(auto x: v) cout<<x.F<<" "<<x.S<<endl;
}
