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 Codeforces {
	public static class Pair{
		int a;
		int b;
		public Pair(int a, int b) {
			this.a = a;
			this.b = b;
		}
	}
	public static BufferedReader br;
	public static void main(String[] args) throws IOException {
		
		br = new BufferedReader(new InputStreamReader(System.in));
		//int cases = Integer.parseInt(br.readLine());
		//while(cases-- > 0) {
			int n = Integer.parseInt(br.readLine());
			//String[] str = br.readLine().trim().split(" ");
			int[] d = ask(1, n);
			List<Pair> adj = new ArrayList<>(n);
			List<Integer> even = new ArrayList<>(), odd = new ArrayList<>();
			for(int i=2; i<=n; i++) {
				if(d[i]%2 == 0) {
					even.add(i);
				}else {
					odd.add(i);
				}
				if(d[i] == 1) {
					adj.add(new Pair(1, i));
				}
			}
			if(even.size() > odd.size()) {
				List<Integer> temp = even;
				even = odd;
				odd = temp;
			}
			for(int u : even) {
				d = ask(u, n);
				for(int v=2; v<=n; v++) {
					if(d[v] == 1) {
						adj.add(new Pair(u, v));
					}
				}
			}
			output(adj);
		//}
	}
	public static int[] ask(int a, int n) throws IOException{
		System.out.println("? "+a);
		System.out.flush();
		int[] ans = new int[n+1];
		String[] str = br.readLine().trim().split(" ");
		for(int i=1; i<=n; i++) {
			ans[i] = Integer.parseInt(str[i-1]);
		}
		return ans;
	}
	public static void output(List<Pair> adj) {
		System.out.println("!");
		for(Pair p : adj) {
			System.out.println(p.a+" "+p.b);
		}
		System.out.flush();
	}
	/*public static void sieveOfEratosthenes(int n, Integer[] factors, ArrayList<Integer> a){
		Arrays.fill(factors, 0);
		factors[1] = 1;
		int p;
		for(p=2; p*p <= n; p++) {
			if(factors[p] == 0) {
				a.add(p);
				factors[p] = p;
				for(int i=p*p; i<=n; i=i+p) {
					factors[i] = p;
				}
			}
		}
		while(p<=n) {
			if(factors[p] == 0) {
				a.add(p);
			}
			p++;
		}
	}*/
	
}
