import java.io.PrintWriter;
import java.util.Scanner;

public class nebuchadnezzar_ak {

    static class P {
        int a, b;

        P(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

    static void swap(int[] a, int[] w, int p1, int p2) {
        int tmp = a[p1];
        a[p1] = a[p2];
        a[p2] = tmp;
        w[a[p1]] = p1;
        w[a[p2]] = p2;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] a = new int[n];
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt() - 1;
            w[a[i]] = i;
        }

        while (true) {
            int p = 0;
            for (int i = 0; i < n; i++) {
                if (w[i] != i) {
                    p = i;
                }
            }
            if (a[p] == p) {
                out.println("Done");
                out.flush();
                return;
            }
            out.println((p + 1) + " " + (w[p] + 1));
            out.flush();
            swap(a, w, p, w[p]);
            p = 0;
            for (int i = 0; i < n; i++) {
                if (w[i] != i) {
                    p = i;
                }
            }
            if (a[p] == p) {
                out.println("Done");
                out.flush();
                return;
            }
            out.println((p + 1) + " " + (w[p] + 1));
            out.flush();
            swap(a, w, p, w[p]);
            int p1 = in.nextInt();
            int p2 = in.nextInt();
//            System.err.println("I'm solution and I just read " + p1 + " and " + p2 + ", array: " + Arrays.toString(a));
            swap(a, w, p1 - 1, p2 - 1);
        }

    }
}
