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>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   (*(x.begin()))
#define le(x)                   (*(x.rbegin()))
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x,id)               (*(x.find_by_order(id)))
#define ook(y)                  order_of_key(y)
#define all(x)                  (x).begin(),(x).end()
#define si(a)                   scanf("%d",&a)
#define sii(a,b)                scanf("%d %d",&a,&b)
#define siii(a,b,c)             scanf("%d %d %d",&a,&b,&c)
#define sl(a)                   scanf("%lld",&a)
#define sll(a,b)                scanf("%lld %lld",&a,&b)
#define slll(a,b,c)             scanf("%lld %lld %lld",&a,&b,&c)
#define rep(i,a,b)              for(ll i = a; i<=b;  i++)
#define un(x)                   x.erase(unique(all(x)), x.end())
#define TT                      long long TC;  scanf("%lld",&TC);  for(ll tc = 1; tc<=TC; tc++)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
#define assign(v,n,x)           v.clear(); for(int I = 0; I<n; I++)    v.pb(x);
#define SZ(x)                   (int)x.size()
#define ff                      first
#define ss                      second
#define FF                      fflush(stdout);
#define ms(AR,x)                memset(AR,x,sizeof AR);
#define case                    printf("Case %lld: ",tc);
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

#define mx 2004

int vis[mx],L[mx];

deque<int> v[mx];


int n;

void fn(int x){
    printf("? %d\n",x);
    FF;
    for(int i = 1; i<=n; i++)
        si(L[i]);
}


main(){
//read;

si(n);

deque<int> xx;

fn(1);

int cnt = 0;

vector<pii> edge;

int even = 0,odd = 0;

for(int i = 1; i<=n; i++){
    if(L[i]==1){
        edge.pb(pii(1,i));
        cnt++;
    }
    if(L[i]%2==0)   even++;
    else odd++;
}

if(even<=odd){
    for(int i = 2; i<=n; i++){
        if(L[i]%2==0)   xx.pb(i);
    }
}
else{
    for(int i = 2; i<=n; i++){
        if(L[i]%2)  xx.pb(i);
    }
}

//int tot = 1;

while(SZ(xx)){
    int u = fe(xx);
    xx.pop_front();
    if(cnt>=n-1)    break;
//    tot++;
    fn(u);
    for(int i = 1; i<=n; i++){
        if(L[i]==1){
            cnt++;
            int a = u,b = i;
            if(a>b) swap(a,b);
            edge.pb(pii(a,b));
        }
    }
}


//cout<<"HI "<<tot<<endl;

sort(all(edge));
un(edge);

puts("!");

for(auto i:edge)
    printf("%d %d\n",i.ff,i.ss);

FF;


return 0;
}


