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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DLostTree solver = new DLostTree();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLostTree {
        ArrayList<Integer>[] a;
        int[] d;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            a = new ArrayList[n];
            for (int i = 0; i < n; ++i) {
                a[i] = new ArrayList<>();
            }

            out.println("? 1");
            out.flush();
            d = in.readArray(n);

            int parity = 0;
            for (int i = 0; i < n; ++i) {
                if (d[i] % 2 == 0) parity++;
                else parity--;
            }

            if (parity <= 0) {
                for (int i = 0; i < n; ++i) {
                    if (d[i] == 1) {
                        a[i].add(0);
                        a[0].add(i);
                    }
                }

                for (int i = 2; i < n; i += 2) {
                    for (int j = 0; j < n; ++j) {
                        if (d[j] == i) {
                            out.println("? " + (j + 1));
                            out.flush();
                            int[] dist = in.readArray(n);
                            for (int k = 0; k < n; ++k) {
                                if (dist[k] == 1) {
                                    a[j].add(k);
                                    a[k].add(j);
                                }
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i < n; i += 2) {
                    for (int j = 0; j < n; ++j) {
                        if (d[j] == i) {
                            out.println("? " + (j + 1));
                            out.flush();
                            int[] dist = in.readArray(n);
                            for (int k = 0; k < n; ++k) {
                                if (dist[k] == 1) {
                                    a[j].add(k);
                                    a[k].add(j);
                                }
                            }
                        }
                    }
                }
            }

            out.println("!");
            dfs(0, -1, out);
            out.flush();
        }

        void dfs(int u, int par, PrintWriter out) {
            for (int v : a[u]) {
                if (v != par) {
                    out.println(u + 1 + " " + (v + 1));
                    dfs(v, u, out);
                }
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

