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.io.*;

public class D1534 {
	static int[] p;
	static Scanner sc;
	static PrintWriter pw;
	static int n;
	static int[] d;
	static int myPar;

	static int[] query(int r) throws IOException {
		r++;
		pw.println("? " + r);
		pw.flush();
		int[] res = sc.nextIntArr(n);
		return res;
	}

	static void processNode(int node) throws IOException {
		int[] myD = query(node);
		for (int i = 0; i < n; i++) {
			if (myD[i] == 1) {
				if (d[i] + 1 == d[node]) {
					p[node] = i;
				} else {
					p[i] = node;
				}
			}
		}
	}

	public static void main(String[] args) throws IOException {
		sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		n = sc.nextInt();
		d = query(0);
		p = new int[n];
		Arrays.fill(p, -1);
		for (int i = 1; i < n; i++) {
			if (d[i] == 1) {
				p[i] = 0;
			}
		}
//		pw.println(Arrays.toString(p));
		int[] cnt = new int[2];
		for (int i = 1; i < n; i++) {
			cnt[d[i] % 2]++;
		}
		if (cnt[0] > cnt[1]) {
			myPar = 1;
		} else {
			myPar = 0;
		}
		for (int i = 1; i < n; i++) {
			if (myPar == d[i] % 2) {
				processNode(i);
			}
		}
//		pw.println(Arrays.toString(p));
		pw.println("!");
		for (int i = 1; i < n; i++) {
			pw.println((i + 1) + " " + (p[i] + 1));
		}
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader f) {
			br = new BufferedReader(f);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}
