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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	
	private static int inputN;
	private static ArrayList<Integer> odds = new ArrayList<>();
	private static ArrayList<Integer> evens = new ArrayList<>();
	private static ArrayList<ArrayList<Integer> > adjList = new ArrayList<>();
	private static boolean[][] used = new boolean[2001][2001];

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		inputN = Integer.parseInt(br.readLine().trim());
		
		for(int i = 0; i <= inputN; ++i) {
			adjList.add(new ArrayList<Integer>());
		}
		
		// first query
		System.out.println("? 1");
		System.out.flush();
		
		String responses = br.readLine().trim();
		StringTokenizer st = new StringTokenizer(responses, " ");
		for(int i = 0; i < inputN; ++i) {
			
			int distance = Integer.parseInt(st.nextToken());
			
			if(distance == 1) {
				adjList.get(1).add(i + 1);
			}
			
			if(distance % 2 == 0) {	
				if(distance != 0) {
					evens.add(i + 1);
				}	
			}else {
				odds.add(i + 1);
			}
			
		}
			
		ArrayList<Integer> minList = evens;
		if(evens.size() > odds.size()) {
			minList = odds;
		}
		
		for(int i = 0; i < minList.size(); ++i) {
			
			System.out.println("? " + minList.get(i));
			System.out.flush();
			
			responses = br.readLine().trim();
			st = new StringTokenizer(responses, " ");
			for(int j = 0; j < inputN; ++j) {
				int distance = Integer.parseInt(st.nextToken());
				if(distance == 1) {
					adjList.get(minList.get(i)).add(j+1);
				}
			}
			
		}
		
		System.out.println("!");
		for(int from = 1; from <= inputN; ++from) {
			for(int i = 0; i < adjList.get(from).size(); ++i) {
				int to = adjList.get(from).get(i);
				if(used[from][to] || used[to][from])
					continue;
				System.out.println(from + " " + to);
				used[from][to] = true;
				used[to][from] = true;
			}
		}
			
		
		
	}

}
