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.util.*;
import java.lang.*;
import java.io.*;

public class feb20 {

	public static void main(String[] srgs) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		int n = Integer.parseInt(scn[0]);
		int[] dist = ask(1, n);
		int odd = 0, even = 0;
		boolean[][] graph = new boolean[n + 1][n + 1];
		boolean[] vis = new boolean[n + 1];
		vis[1] = true;
		for (int i = 1; i < n; i++) {
			if (dist[i] % 2 == 0) {
				even += 1;
			} else {
				odd += 1;
			}
			if (dist[i] == 1) {
				graph[i + 1][1] = graph[1][i + 1] = true;
			}
		}
		ArrayList<Integer> tocheck = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			if (odd <= even) {
				if (dist[i] % 2 == 1) {
					tocheck.add(i + 1);
				}
			} else {
				if (dist[i] % 2 == 0) {
					tocheck.add(i + 1);
				}
			}
		}

		for (int node : tocheck) {
			dist = ask(node, n);
			for (int i = 0; i < n; i++) {
				if (dist[i] == 1) {
					graph[i + 1][node] = graph[node][i + 1] = true;
				}
			}
		}
		StringBuilder sb = new StringBuilder();

		sb.append("!\n");

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (graph[i][j]) {
					sb.append(i + " " + j);
					sb.append("\n");
				}
			}
		}
		System.out.println(sb);
		return;

	}

	public static int[] ask(int node, int n) throws Exception {
		System.out.println("? " + node);
		System.out.flush();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = br.readLine().trim().split(" ");
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			ans[i] = Integer.parseInt(scn[i]);
		}
		return ans;
	}

	public static void sec() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();
		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			long[] arr = new long[n];
			scn = (br.readLine()).trim().split(" ");
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(scn[i]);
			}
			sb.append("\n");
		}
		System.out.println(sb);
		return;

	}

	public static void third() throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] scn = (br.readLine()).trim().split(" ");
		int n = Integer.parseInt(scn[0]);
		long[] arr = new long[n];
		scn = (br.readLine()).trim().split(" ");
		for (int i = 0; i < n; i++) {
			arr[i] = Long.parseLong(scn[i]);
		}
		System.out.println(sb);
		return;

	}

	public static void sort(long[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			long temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}

		Arrays.sort(arr);
	}

	public static void sort(int[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			int temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}
		Arrays.sort(arr);
	}

	public static void print(long[][] dp) {
		for (long[] a : dp) {
			for (long ele : a) {
				System.out.print(ele + " ");
			}
			System.out.println();
		}
	}

	public static void print(int[][] dp) {
		for (int[] a : dp) {
			for (int ele : a) {
				System.out.print(ele + " ");
			}
			System.out.println();
		}
	}

	public static void print(boolean[] dp) {
		for (boolean ele : dp) {
			System.out.print(ele + " ");
		}
		System.out.println();
	}

	public static void print(long[] dp) {
		for (long ele : dp) {
			System.out.print(ele + " ");
		}
		System.out.println();
	}

	public static void debug() {
		System.out.println("working..");
	}

	public static void debug(int i) {
		System.out.println("working on " + i);
	}

}
