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

// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <stdio.h>
#include <map>
#include <math.h>
#include <set>
#include <fstream>
#include <queue>

using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    for(auto v : V) os << v << " ";
    return cout << "";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    for(auto s:S) os<<s<<" ";
    return cout << "";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << P.first << " " << P.second;
}
ll mod=1000000007;
#define inf 9999999999999

ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}

ll gcd(ll a,ll b){ if (b==0) return a;return gcd(b,a%b);}

ll pwr(ll a, ll b) {a %= mod; ll res = 1;while (b > 0) {if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1;}return res;}

//Template ends
vector<vector<int> > adj;
vector<int> vis;
int d[2010];
int main(){
    int t,n;
    int i,j;
    cin >> n;
    
    cout << "? " << 1 << endl << flush;
    int evncnt = 0;
    for(i=1;i<=n;i++){
        cin >> d[i];
        if(d[i]%2==0) evncnt++;
    }
    int oddcnt = n-evncnt;
    
    int start=1;
    
    queue<int> q;
    q.push(1);
    adj.assign(n+1,{});
    vis.assign(n+1,0);
    vis[1]=1;
    
    if(oddcnt<evncnt){
        while(d[start]%2==0) start++;
        q = queue<int>();
        q.push(start);
        vis[1] = 0;
        vis[start] = 1;
    }
    else{
        q.pop();
        for(i=1;i<=n;i++){
            if(d[i]==2){
                if(!vis[i]){
                    vis[i] = 1;
                    q.push(i);
                }
            }
            if(d[i]==1){
                adj[1].pb(i);
                adj[i].pb(1);
            }
        }
    }
    
    
    while(!q.empty()){
        int v = q.front();
        q.pop();
        cout << "? " << v << endl << flush;
        for(i=1;i<=n;i++){
            cin >> d[i];
            if(d[i]==2){
                if(!vis[i]){
                    vis[i] = 1;
                    q.push(i);
                }
            }
            if(d[i]==1){
                adj[v].pb(i);
                adj[i].pb(v);
            }
        }
        
        
    }
    cout << "!\n";
    for(i=1;i<=n;i++){
        for(int u:adj[i]){
            if(u>i) cout << i << " " << u << endl;
        }
    }
    cout << flush;
}
