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.ArrayList;
import java.util.Scanner;

public class ArmyOfTheNight {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            g[i] = new ArrayList<>();
        }
        System.out.println("? 1");
        System.out.flush();
        ArrayList<Integer> even = new ArrayList<>();
        ArrayList<Integer> odd = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int d = in.nextInt();
            if (d % 2 == 0) {
                even.add(i);
            } else {
                odd.add(i);
            }
            if (d == 1) {
                g[0].add(i);
            }
        }
        ArrayList<Integer> a = even;
        if (odd.size() < even.size()) {
            a = odd;
        }
        for (int j = 0; j < a.size(); j++) {
            int v = a.get(j);
            if (v != 0) {
                System.out.println("? " + (v + 1));
                System.out.flush();
                for (int i = 0; i < n; i++) {
                    if (in.nextInt() == 1 && i != 0) {
                        g[v].add(i);
                    }
                }
            }
        }
        System.out.println("!");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < g[i].size(); j++) {
                System.out.println((i + 1) + " " + (g[i].get(j) + 1));
            }
        }
        System.out.flush();
    }
}