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
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>PBDS;
#define mod 1000000007
#define INF 10000000000007
#define DEBUG false
#define N 100005
ll gcd(ll a , ll b) {return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b)
{
	return (a / gcd(a, b)) * b;
}
int n;
 
vector<int> query(int x) {
	x++;
	cout << "? " << x << endl;
	vector<int> res(n);
	for (int i = 0; i < n; i++) {
		cin >> res[i];
	}
	return res;
}
 
void solve() {
	cin >> n;
	vector<pair<int, int>> res;
	vector<int> a = query(0);
	int dist[2];
	dist[0] = dist[1] = 0;
	for (int i = 0; i < n; i++) {
		dist[a[i] % 2]++;
	}
	if (dist[0] == dist[1] || (dist[0] < dist[1])) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				vector<int> b;
				if (i == 0) b = a;
				else b = query(i);
				for (int j = 0; j < n; j++) {
					if (b[j] == 1) res.push_back({min(i, j), max(i, j)});
				}
			}
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2) {
				vector<int> b;
				if (i == 0) b = a;
				else b = query(i);
				for (int j = 0; j < n; j++) {
					if (b[j] == 1) res.push_back({min(i, j), max(i, j)});
				}
			}
		}
	}
	sort(res.begin(), res.end());
	res.resize(unique(res.begin(), res.end()) - res.begin());
	cout << "!\n";
	for (auto x : res) {
		cout << x.first + 1 << " " << x.second + 1 << endl;
	}
	return ;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ll t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
