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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class D {

    public static int n;

    public static HashSet<String> ans;

    public static boolean[] connected;

    public static BufferedReader br;

    public static void main(String[] args) throws IOException {

        br = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(br.readLine());
        ans = new HashSet<>();
        connected = new boolean[n];
        HashSet<Integer> done = new HashSet<>();
        for (int i = 0; i < n; i++) {
            if (!connected[i]) {
                query(i);
                done.add(i);
            }
        }
        for (int i = 0; i < n && ans.size() < n - 1; i++) {
            if (!done.contains(i)) {
                query(i);
                done.add(i);
            }
        }
        System.out.println("!");
        for (String edge : ans) {
            System.out.println(edge);
        }

    }

    public static void query(int i) throws IOException {

        System.out.println("? " + (i + 1));
        System.out.flush();
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] l = new int[n];
        int[] f = new int[n];
        HashMap<Integer, ArrayList<Integer>> m = new HashMap<>();
        for (int j = 0; j < n; j++) {
            l[j] = Integer.parseInt(st.nextToken());
            f[l[j]]++;
        }
        for (int j = 0; j < n; j++) {
            if (!m.containsKey(l[j])) {
                m.put(l[j], new ArrayList<>());
            }
            m.get(l[j]).add(j);
        }
        connected[i] = true;
        int last = i;
        for (int k = 1; k <= n; k++) {
            if (f[k - 1] <= 1 && m.containsKey(k)) {
                for (int w : m.get(k)) {
                    String key = last < w ? (last + 1) + " " + (w + 1) : (w + 1) + " " + (last + 1);
                    if (!ans.contains(key)) {
                        ans.add(key);
                        connected[w] = true;
                    }
                    if (m.get(k).size() == 1) {
                        last = w;
                    }
                }
            } else {
                break;
            }
        }

    }

}
