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

#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {return (rng() % (y-x +1)) + x;};

#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector
#define mxe max_element
#define mne max_element
#define present(c, x) (c.find(x) != c.end())
#define printall(a) for(auto i : a) cout << i << " " ; cout << nl ;
#define ld long double 

#define int long long

typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vii> vvi;
typedef vector<vll> vvl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const ll INF = (ll) 1e18;

inline int add(int a, int b) {return (a + b >= mod ? a + b - mod : a + b);}
inline int mul(int a, int b) {return (ll) a * b % mod ; }

void solve() {

    int n; cin >> n ;
    set<pii> e ; 
    cout << "? 1" << endl ; 
    int d[n+1] ;
    vii v[2] ; 
    rep(i,1,n+1) {
        cin >> d[i] ; 
        if(d[i] == 1) {
            e.ins({1, i}) ; 
        }
        if(d[i]) v[d[i]&1].pb(i) ; 
    }

    if(sz(v[0]) > sz(v[1])) swap(v[0], v[1]) ; 

    for(auto i : v[0]) {
        cout << "? " << i << endl ; 
        rep(j,1,n+1) {
            cin >> d[j] ; 
            if(d[j] == 1) {
                e.ins({min(j, i), max(j, i)}) ; 
            }
        }
    }

    cout << "!" << endl ; 
    for(auto [x,y] : e) cout << x << " " << y << endl ; 
}   

int32_t main() {

    fast;
    // int t; cin >> t ; rep(i,0,t) 
        solve() ;
    // cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}