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 LATOKEN {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = 1;
        while (t-- > 0) {
            int n = sc.nextInt();
            if (n == 2) {
                System.out.println("!");
                System.out.println("1 2");
                System.out.flush();
                continue;
            }
            ArrayList<Pair> e = new ArrayList<>();
            System.out.println("? 1");
            System.out.flush();
            int [] dist = new int[n + 1];
            ArrayList<Integer> even = new ArrayList<>();
            ArrayList<Integer> odd = new ArrayList<>();
            int [][] got = new int[n + 1][n + 1];
            for (int i = 1; i <= n; i++) {
                dist[i] = sc.nextInt();
                if (dist[i] % 2 == 0) even.add(i);
                else odd.add(i);
                if (dist[i] == 1) {
                    got[i][1] = 1;
                    got[1][i] = 1;
                    e.add(new Pair(i, 1));
                }
            }
            if (even.size() <= odd.size()) {
                for (Integer i: even) {
                    if (i == 1) continue;
                    System.out.println("? " + i);
                    System.out.flush();
                    for (int j = 1; j <= n; j++) {
                        int x = sc.nextInt();
                        if (x == 1 && got[j][i] == 0) {
                            got[j][i]++;
                            got[i][j]++;
                            e.add(new Pair(i, j));
                        }
                    }
                }
            } else {
                for (Integer i: odd) {
                    if (i == 1) continue;
                    System.out.println("? " + i);
                    System.out.flush();
                    for (int j = 1; j <= n; j++) {
                        int x = sc.nextInt();
                        if (x == 1 && got[j][i] == 0) {
                            got[j][i]++;
                            got[i][j]++;
                            e.add(new Pair(i, j));
                        }
                    }
                }
            }
            System.out.println("!");
            for (Pair p: e) {
                System.out.println(p.i + " " + p.j);
            }
            System.out.flush();
        }
        out.close();
    }

    static class Pair {
        int i; int j;
        Pair(int i, int j) {
            this.i = i; this.j = j;
        }
    }


    static void sort(int[] a) {
        ArrayList<Integer> q = new ArrayList<>();
        for (int i : a) q.add(i);
        Collections.sort(q);
        for (int i = 0; i < a.length; i++) a[i] = q.get(i);
    }

    static void sort(long[] a) {
        ArrayList<Long> q = new ArrayList<>();
        for (long i : a) q.add(i);
        Collections.sort(q);
        for (int i = 0; i < a.length; i++) a[i] = q.get(i);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}