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 ll = long long;
#define all(x) (x).begin(), (x).end()
int main() {
//	std::ios_base::sync_with_stdio(false);
//	std::cin.tie(nullptr);
//	std::cout.tie(nullptr);
	int n;
	std::cin >> n;
	auto ask = [&] (int x) {
		std::cout << "? " << x + 1 << "\n";
		std::vector<int> res(n);
		for (int &x : res) std::cin >> x;
		return res;
	};
	std::vector<int> d = ask(0);
	std::vector<std::pair<int, int>> ans;
	std::vector<std::vector<int>> cat(2);
	for (int i = 0; i < n; ++i) {
		if (d[i] == 1) ans.emplace_back(std::make_pair(0, i));
	}
	for (int i = 1; i < n; ++i) {
		if (d[i] & 1) cat[1].emplace_back(i);
		else cat[0].emplace_back(i);
	}
	std::vector<int> point;
	if (cat[0].size() > cat[1].size()) point = cat[1];
	else point = cat[0];
	for (int x : point) {
		d = ask(x);
		for (int i = 0; i < n; ++i) {
			if (d[i] == 1) ans.emplace_back(std::make_pair(x, i));
		}
	}
	for (auto &x : ans) {
		if (x.first > x.second) std::swap(x.first, x.second);
	}
	std::sort(all(ans));
	ans.erase(std::unique(all(ans)), ans.end());
	std::cout << "!\n";
	for (auto x : ans) std::cout << x.first + 1 << " " << x.second + 1 << "\n";
	return 0;
}