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 codeforcesLATOKEN1_D {
    private static void solve(FastIOAdapter ioAdapter) {
        int n = ioAdapter.nextInt();

        ioAdapter.out.println("? 1");
        ioAdapter.out.flush();
        int[] a = ioAdapter.readArray(n);
        HashSet<String> res = new HashSet<>();
        HashSet<Integer> even = new HashSet<>();
        HashSet<Integer> odd = new HashSet<>();
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                even.add(i + 1);
            } else if (a[i] % 2 != 0) {
                odd.add(i + 1);
            }
        }
        HashSet<Integer> chosen;
        if (even.size() <= odd.size() + 1) {
            chosen = even;
            chosen.remove(1);
            for (int i = 0; i < n; i++) {
                if (a[i] == 1) {
                    res.add(1 + " " + (i + 1));
                }
            }
        } else chosen = odd;
        for (Integer num : chosen) {
            ioAdapter.out.println("? " + num);
            ioAdapter.out.flush();
            int[] cur = ioAdapter.readArray(n);
            for (int i = 0; i < n; i++) {
                if (cur[i] == 1) {
                    res.add(num + " " + (i + 1));
                }
            }
        }

        ioAdapter.out.println("!");
        for (String str : res) {
            ioAdapter.out.println(str);
        }
        ioAdapter.out.flush();
    }

    public static void main(String[] args) throws Exception {
        try (FastIOAdapter ioAdapter = new FastIOAdapter()) {
            int count = 1;
            //count = ioAdapter.nextInt();
            while (count-- > 0) {
                solve(ioAdapter);
            }
        }
    }

    static void shuffleSort(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for (int i = 0; i < n; ++i) {
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n - i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        Arrays.sort(arr);
    }

    static class FastIOAdapter implements AutoCloseable {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter((System.out))));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        @Override
        public void close() throws Exception {
            out.flush();
            out.close();
            br.close();
        }
    }
}