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;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define FOR(i, a) for(int i = 0; i < (a); ++i)
#define rrep(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
#define ft first
#define sd second
#define pb push_back
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;

const ll MOD = 1000000007;

void ask(int n){
    cout<<"? "<<n<<endl;
}

void solve(){
    int n;cin>>n;
    vector<set<int>> g(n+1);
    ask(1);
    int a[n+1];
    int zero(0),one(0);
    rep(i,0,n){
        cin>>a[i+1];
        if (a[i+1]==1) g[1].insert(i+1);
        a[i+1]%=2;
        if (a[i+1]) one++;
        else zero++;
    }
    int ma=(min(zero,one)==zero)?0:1;
    if (ma==1) g[1].clear();
    //cout<<one<<" "<<zero<<" "<<ma<<endl;
    rep(i,2,n+1){
        if (a[i]==ma){
            ask(i);
            rep(j,0,n){
                int x;cin>>x;
                if (x==1){
                    g[i].insert(j+1);
                }
            }
        }
    }
    cout<<'!'<<endl;
    rep(i,1,n+1){
        trav(x,g[i]){
            cout<<i<<" "<<x<<endl;
        }
    }

}

int main(){
    int t(1);//cin>>t;
    while (t--){
        solve();
        cout<<endl;
    }
	return 0;
}
