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


/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 13 June 2021 10:08:08 PM
*/

#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main(){
 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   
    int n;
    cin >> n;

    set < pair < int, int > > s;

    auto ask = [&](int i){
        cout << "? " << i+1 << endl;
        vector < int > ans(n);
        for(auto &x: ans) cin >> x;
        for(int j=0; j<n; ++j){
            if(ans[j] == 1){
                s.insert( { min(i, j), max(i, j) } );
            }
        }
        return ans;
    };

    vector < vector < int > > dis(n);
    vector < int > depth = ask(0);
    //assuming root at 1
    // now we have depth of all child
    // can we take max and then continue our queries ?
    // lets see
    auto ans = [&](){
        cout << "! " << "\n";
        for(auto x: s){
            cout << x.first+1 << " " << x.second+1 << "\n";
        }
    };
    
    int cnt[2]={};
    for(int i=0; i<n; ++i){
        cnt[depth[i]%2]++;
    }

    int u = ( ( cnt[0] > cnt[1] ) ? 1 : 0 );

    for(int i=1; i<n; ++i){
        if(depth[i]%2 == u){
            ask(i);
        }
    }
    ans(); 
    return 0;
}
