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

import java.io.*;
import java.util.*;

public class CF1534D extends PrintWriter {
	CF1534D() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1534D o = new CF1534D(); o.main(); o.flush();
	}

	int n;
	void query(int[] dd, int i) {
		println("? " + (i + 1));
		for (int j = 0; j < n; j++)
			dd[j] = sc.nextInt();
	}
	void main() {
		n = sc.nextInt();
		if (n == 2) {
			println("!");
			println("1 2");
			return;
		}
		int[] ii = new int[n - 1], jj = new int[n - 1]; int cnt = 0;
		int[] d0 = new int[n];
		query(d0, 0);
		for (int i = 1; i < n; i++)
			if (d0[i] == 1) {
				ii[cnt] = 0; jj[cnt] = i; cnt++;
			}
		Integer[] hh = new Integer[n];
		for (int i = 0; i < n; i++)
			hh[i] = i;
		Arrays.sort(hh, (i, j) -> d0[i] - d0[j]);
		boolean[] used = new boolean[n + 1]; used[0] = true;
		int[] dd = new int[n];
		for (int h = n - 1; h > 0 && cnt < n - 1; h--) {
			int i = hh[h];
			if (used[i] || d0[i] <= 1)
				continue;
			query(dd, i);
			int j = 0;
			while (used[j] || dd[j] != 1)
				j++;
			ii[cnt] = i; jj[cnt] = j; cnt++;
			used[i] = used[j] = true;
			for (int k = 0; k < n; k++)
				if (!used[k] && dd[k] == 2) {
					if (d0[k] == d0[i])
						used[k] = true;
					ii[cnt] = j; jj[cnt] = k; cnt++;
				}
		}
		println("!");
		while (cnt-- > 0)
			println((ii[cnt] + 1) + " " + (jj[cnt] + 1));
	}
}
