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

public class nebuchadnezzar_ak_random_and_check {

    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;
        }

        Random rnd = new Random(3);

        while (true) {
            boolean done = true;
            for (int i = 0; i < n; i++) {
                done &= a[i] == i;
            }
            if (done) {
                out.println("Done");
                out.flush();
                return;
            }

            int p1 = rnd.nextInt(n);
            int p2 = rnd.nextInt(n);
            while (p1 == p2) {
                p1 = rnd.nextInt(n);
                p2 = rnd.nextInt(n);
            }
            out.println((p1 + 1) + " " + (p2 + 1));
            out.flush();
            swap(a, w, p1, p2);

            done = true;
            for (int i = 0; i < n; i++) {
                done &= a[i] == i;
            }
            if (done) {
                out.println("Done");
                out.flush();
                return;
            }

            p1 = rnd.nextInt(n);
            p2 = rnd.nextInt(n);
            while (p1 == p2) {
                p1 = rnd.nextInt(n);
                p2 = rnd.nextInt(n);
            }

            out.println((p1 + 1) + " " + (p2 + 1));
            out.flush();
            swap(a, w, p1, p2);
            p1 = in.nextInt();
            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);
        }


    }
}
