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;
#define ll long long
#define mp make_pair
#define pb push_back
#define ins insert
#define MOD 1e9+7
#define MAXN 100001
#define Pq priority_queue
#define u_set unordered_set
#define set_val(arr,v) memset(arr, v, sizeof(arr))
#define FOR(i,from,to) for(int i=from; i<to; i++)
#define FOL(i,from,to) for(int i=from; i>=to; i--)
#define YES cout << "YES" << endl 
#define NO cout << "NO" << endl
#define B() begin()
#define E() end()
#define F first
#define S second


unordered_map<int, u_set<int>> gr;

void ask(int v, vector<int>& d) {
	cout << "? " << v << endl;
	cout.flush();

	FOR(i,0,d.size()) {
		cin >> d[i];
		if(i && d[i] == 1) gr[v].ins(i+1);
	}
}

int solve() {
	int n;
	cin >> n;

	vector<int> d(n);
	
	ask(1, d);
	int ev = 0, od = 0;
	FOR(i,0,n) {
		if(d[i] % 2) od++;
		else ev++;
	}

	int rem = ev > od ? 1 : 0;
	FOR(i,1,n) {
		if(d[i] % 2 == rem) {
			vector<int> d1(n);
			ask(i+1, d1);
		}
	}

	cout << "!" << endl;
	for(auto kv : gr)
		for(auto v : kv.S)
			cout << kv.F << " " << v << endl;
	
	return 0;
}

int main() {
	ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
	int t=1;
	// cin >> t;
	while(t--)
		solve();
	
	return 0; 
}