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 D {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(f.readLine());
        boolean[][] mat = new boolean[n+1][n+1];
        ArrayList<Integer> c1 = new ArrayList<Integer>();
        ArrayList<Integer> c2 = new ArrayList<Integer>();
        out.println("? 1");
        out.flush();
        int[] dists = new int[n];
        StringTokenizer st = new StringTokenizer(f.readLine());
        for(int i = 0; i < n; i++) dists[i] = Integer.parseInt(st.nextToken());
        for(int i = 0; i < n; i++){
            if(dists[i] == 0) continue;
            if(dists[i] == 1){
                mat[1][i+1] = true;
                mat[i+1][1] = true;
            }
            if(dists[i] % 2 == 0) c1.add((i+1));
            else c2.add((i+1));
        }
        ArrayList<Integer> curList;
        if(c2.size() >= c1.size()){
            curList = c1;
        }else{
            curList = c2;
        }
        for(int idx: curList){
            out.println("? "+idx);
            out.flush();
            st = new StringTokenizer(f.readLine());
            for(int i = 0; i < n; i++){
                int temp = Integer.parseInt(st.nextToken());
                if(temp == 1){
                    mat[idx][i+1] = true;
                    mat[i+1][idx] = true;
                }
            }
        }
        out.println("!");
        for(int i = 1; i <= n; i++){
            for(int j = i+1; j <= n; j++){
                if(mat[i][j]){
                    out.println(i+" "+j);
                }
            }
        }

        out.close();
    }
}
