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;

#ifdef LOCAL
#include "tw.h"
#define debug(...); cerr<<"[ "; _pr(#__VA_ARGS__); cerr<<": "; _pr(__VA_ARGS__); cerr<<(" ]\n");
#define SET_DEBUG(); freopen("debug.txt", "w", stderr); cerr.tie(0);
#else
#define debug(...);
#define SET_DEBUG();
#endif

#define FASTIO(); ios::sync_with_stdio(0); cin.tie(0);
#define FILE_IN(); freopen("input.txt", "r", stdin); 
#define FILE_OUT(); freopen("output.txt", "w", stdout);
#define FILE(); FILE_IN(); FILE_OUT();
#define int long long
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define ppb pop_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define nl '\n'
#define sp ' '

const long double PI=3.141592653589793238;
const int mod=1e9+7;
const int mod2=998244353;
const int INF=1e18;

//observe, brute-force, greedy, dp, binary-search

int n;
vector<int> zero_query;

void query(int r, vector<int> &res){
	if(r==0){
		if(zero_query.size()!=0) {
			res=zero_query;
			return;
		}
	}
	r++;
	cout<<"? "<<r<<endl;
	for(int &i: res) cin>>i;
	if(zero_query.size()==0) zero_query=res;
}

void solve(){

	int n; cin>>n;

	vector<int> res(n);
	query(0, res);

	vector<pair<int, int>> edges;
	vector<int> to_use;

	vector<int> depth(n);
	int odd_depth=0, even_depth=0, max_depth=0;
	for(int i=0; i<n; ++i){
		depth[i]=res[i];
		if(depth[i]%2) odd_depth++;
		else even_depth++;
		max_depth=max(max_depth, depth[i]);
	}

	int start=0;
	if(odd_depth<even_depth) start=1;

	for( ; start<=max_depth; start+=2){
		for(int i=0; i<n; ++i){
			if(depth[i]==start){
				query(i,res);
				for(int j=0; j<n; ++j){
					if(res[j]==1){
						edges.pb({i,j});
					}
				}
			}
		}
	}

	cout<<"!"<<nl;

	for(pair<int, int> p: edges){
		cout<<p.ff+1<<sp<<p.ss+1<<nl;
	}

	cout<<endl;

}

signed main(){

	SET_DEBUG();
	FASTIO();
	// FILE();
	int ts=1;
	//cin>>ts;
	for(int t=0; t<ts; ++t) {
		solve();
	}
	return 0;

}

