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 <array>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll = vector<pll>;
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (const auto &x : v) os << x << " "; return os; }
template<typename T, size_t Size> ostream& operator<<(ostream &os, const array<T, Size> &v) { for (const auto &x : v) os << x << " "; return os; }

vector<int> ask(int v, int n, set<pair<int, int>>& res) {
	cout << "? " << v + 1 << endl;
	vector<int> d(n);
	for (int i=0; i<n; i++) {
		cin >> d[i];
		if (d[i] == 1)
			res.emplace(min(v, i), max(v, i)); // sort vertices numbers
	}
	return d;
}

void solve() {
	int n;
	cin >> n;
	set<pair<int, int>> res;
	auto d = ask(0, n, res);
	vector<int> cnt(2, 0); // cnt number of pair and impair distances
	for (int i = 0; i < n; i++)
		cnt[d[i] % 2] += 1;
	int u = (cnt[0] > cnt[1] ? 1 : 0);
	for (int i = 1; i < n; i++) {
		if (d[i] % 2 == u)
			ask(i, n, res);
	}
	cout << "!" << endl;
	for (auto& p : res)
		cout << p.first + 1 << " " << p.second + 1 << endl;
}

int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
	ifstream in("inputD.txt");
	cin.rdbuf(in.rdbuf()); //redirect cin to input.txt!
	ofstream out("outD.txt");
	cout.rdbuf(out.rdbuf()); //redirect cout to out.txt!
#endif
	solve();
	return 0;
}
