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 lostTree {
    
    
    public static void main(String[] args) {
        int n = i();

        System.out.println("? " + 1);
        System.out.println();

        int[][] graph = new int[n+1][n+1];
        int[] arr = readArray(n);
        System.out.flush();
        
        int odd = 0, even = 0;
        for(int i=0; i<n; i++) {
            if(arr[i] == 1) {
                graph[i+1][1] = 1;
                graph[1][i+1] = 1;
            }
            if(arr[i] % 2 == 0) {
                even++;
            }        
            else {
                odd++;
            }
        }
        
        int check = -1;
        if(even <= odd) {
            check = 0;
        } else {
            check = 1;
        }

        for(int i=2; i<=n; i++) {
            if(arr[i-1] % 2 != check) 
                continue;
            
            System.out.println("? " + i);
            System.out.println();

            int[] newarr = readArray(n);
            System.out.flush();

            for(int j=0; j<n; j++) {
                if(newarr[j] == 1) {
                    graph[i][j+1] = 1;
                    graph[j+1][i] = 1;
                }
            }
        }

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

    public static int i() {
        Scanner scn = new Scanner(System.in);
        return scn.nextInt();
    }
    
    public static int[] readArray(int n) {
        Scanner scn = new Scanner(System.in);
        int[] arr = new int[n];
        for(int i=0; i<n; i++)
            arr[i] = scn.nextInt();
        return arr;
    }
}
