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.lang.reflect.Array;
import java.util.*;

public class Codeforces {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod = 1000000007;

    static int getInt() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    static long getLong() throws IOException {
        return Long.parseLong(br.readLine());
    }

    static int[] getIntArray() throws IOException {
        String[] arString = br.readLine().split(" ");
        int[] ar = new int[arString.length];
        for (int i = 0; i < ar.length; i++) {
            ar[i] = Integer.parseInt(arString[i]);
        }
        return ar;
    }

    static long[] getLongArray() throws IOException {
        String[] arString = br.readLine().split(" ");
        long[] ar = new long[arString.length];
        for (int i = 0; i < ar.length; i++) {
            ar[i] = Long.parseLong(arString[i]);
        }
        return ar;
    }

    static List<Integer> getIntList() throws IOException {
        String[] arString = br.readLine().split(" ");
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < arString.length; i++) {
            list.add(Integer.parseInt(arString[i]));
        }
        return list;
    }

    static List<Long> getLongList() throws IOException {
        String[] arString = br.readLine().split(" ");
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < arString.length; i++) {
            list.add(Long.parseLong(arString[i]));
        }
        return list;
    }

    static class Pair {
        Integer first;
        Integer second;

        Pair(Integer f, Integer s) {
            this.first = f;
            this.second = s;
        }

        public String toString() {
            return "(" + this.first + ", " + this.second + ")";
        }

        @Override
        public boolean equals(Object object) {
            if (((Pair) object).first == this.first && ((Pair) object).second == this.second
                    && object instanceof Pair) {
                return true;
            } else {
                return false;
            }
        }
    }

    public static int gcd(int a, int b) {
        if (a > b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    public static void main(String[] args) throws IOException {
        int n = getInt();
        System.out.println("? 1");
        System.out.flush();
        int[] ar = getIntArray();
        int oddCount = 0, evenCount = 0;
        boolean[][] edges = new boolean[n][n];

        List<Integer> even = new ArrayList<>(), odd = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (ar[i] % 2 == 0) {
                evenCount += 1;
                if (i != 0)
                    even.add(i);
            } else {
                oddCount += 1;
                odd.add(i);
            }
            if (ar[i] == 1)
                edges[0][i] = edges[i][0] = true;
        }
        boolean e = false;
        if (evenCount <= (n + 1) / 2)
            e = true;
        

        List<Integer> finalAr = e ? even : odd;
        for (int i : finalAr) {
            System.out.println("? " + (i + 1));
            System.out.flush();
            int[] newAr = getIntArray();
            for (int j = 0; j < newAr.length; j++) {
                if (newAr[j] == 1)
                    edges[i][j] = edges[j][i] = true;
            }
        }

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

}