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 ll long long
#define pb push_back
#define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
#define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
#define sortV(v) sort(v.begin(),v.end())
#define revV(v) reverse(v.begin(),v.end())


ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
string str = "", s1 = "", s2 = "";
ll mod = 1e9 + 7;
//ll mod = 998244353;
//const int N = 100009;
const int N = 509;



void solve(){
    cin >> n;
    cout << "? 1" << endl;   
    set<ll> odds;
    set<ll> evens;
    set<pair<ll,ll>> st;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(a % 2){
            if(a == 1){
                st.insert({1, i});
            }odds.insert(i);
        }else{
            if(a != 0) evens.insert(i);
        }
    } 
    set<ll> newSt;
    ll sz1 = odds.size();
    ll sz2 = evens.size();
    if(sz1 <= sz2) newSt = odds;
    else newSt = evens;
    while(st.size() != (n - 1)){
        ll f = *(newSt.begin());
        cout << "? " << f << endl;
        for(ll i = 1; i <= n; i++){
            cin >> a;
            ll mn = min(i, f);
            ll mx = max(i, f);
            if(!st.count({mn, mx}) && a == 1){
                st.insert({mn, mx});
            }
        }
        newSt.erase(*(newSt.begin()));
    }
    cout << "!" << endl;
    for(auto it : st){
        cout << it.first << " " << it.second << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout); 

   

    int cases = 1;
    //cin >> cases;


    while(cases--) solve();
    return 0;
}