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.Collection;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Queue;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.util.Collections;
import java.io.InputStream;

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

    static class DPoteryannoeDerevo {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
//        7
//                ? 0
//        0 1 1 2 2 2 2
//                ? 1
//        1 0 2 1 1 3 3
//                ? 2
//        1 2 0 3 3 1 1
            Vertex[] vs = Vertex.emptyGraph(n);
            boolean[] c = new boolean[n];
            Queue<Integer> queue = new LinkedList<>();
            queue.add(0);
            while (!queue.isEmpty()) {
                int i = queue.poll();

                out.println("? " + (i + 1));
                out.flush();

                Map<Integer, List<Integer>> m = new HashMap<>();
                for (int h = 0; h < n; h++) {
                    int val = in.nextInt();
                    if (!m.containsKey(val)) {
                        m.put(val, new ArrayList<>());
                    }
                    m.get(val).add(h);
                }
                if (!c[i] && i != 0) {
                    for (Integer to : m.get(1)) {
                        if (c[to]) {
                            vs[to].adj.add(vs[i]);
                        }
                    }
                }
                c[i] = true;

                Vertex prev = vs[i];
                for (int h = 1; h < n; h++) {
                    if (!m.containsKey(h)) {
                        break;
                    }
                    List<Integer> a = m.get(h);
                    int ct = 0;
                    Vertex prevCand = null;
                    for (Integer to : a) {
                        if (c[to]) {
                            continue;
                        }
                        ct++;
                        c[to] = true;
                        prev.adj.add(vs[to]);
                        prevCand = vs[to];
                    }
                    if (ct > 1) {
                        int ct2 = 0;
                        for (Integer to : m.getOrDefault(h + 1, Collections.emptyList())) {
                            if (!c[to]) {
                                ct2++;
                            }
                        }
                        if (ct2 > 0) {
                            if (ct >= ct2) {
                                queue.addAll(m.get(h + 1));
                            } else {
                                queue.addAll(a);
                            }
                        }
                        break;
                    }
                    if (ct == 0) {
                        continue;
                    }
                    prev = prevCand;
                }
            }
            out.println("!");
            out.flush();
            for (Vertex v : vs) {
                for (Vertex to : v.adj) {
                    out.println((v.idx + 1) + " " + (to.idx + 1));
                    out.flush();
                }
            }
        }

    }

    static class Vertex {
        int idx;
        List<Vertex> adj = new ArrayList<>();

        public static Vertex[] emptyGraph(int n) {
            Vertex[] vs = new Vertex[n];
            for (int i = 0; i < n; i++) {
                vs[i] = new Vertex();
                vs[i].idx = i;
            }
            return vs;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

