import ru.ifmo.testlib.Checker;
import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;
import ru.ifmo.testlib.Outcome.Type;

import java.util.Arrays;
import java.util.HashSet;

public class Check implements Checker {
    public final String IMPOSSIBLE = "Impossible";

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        String jans = ans.nextToken();
        String pans = ouf.nextToken();
        if (jans.equals(IMPOSSIBLE) && pans.equals(IMPOSSIBLE)) {
            return new Outcome(Type.OK, IMPOSSIBLE);
        }
        if (!jans.equals(IMPOSSIBLE) && pans.equals(IMPOSSIBLE)) {
            return new Outcome(Type.WA, "Solution not found");
        }
        int n = inf.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = inf.nextInt();
        }

        int k;
        try {
            k = Integer.parseInt(pans);
        } catch (NumberFormatException nfe) {
            return new Outcome(Type.PE, "Wrong number: " + pans);
        }
        if (k < 1 || k > n - 1) {
            return new Outcome(Type.WA, "Wrong number of left soldiers: " + k);
        }

        int[] left = new int[k];
        for (int i = 0; i < k; i++) {
            left[i] = ouf.nextInt();
            if (left[i] < 1 || left[i] > n) {
                return new Outcome(Type.WA, "Wrong index of soldier: " + left[i]);
            }
            if (i > 0 && left[i] <= left[i - 1]) {
                return new Outcome(Type.WA, "Non increasing sequence of indexes of left soldiers: " + left[i - 1] + " then " + left[i]);
            }
        }
        int[] right = new int[n - k];
        int j = 0;
        for (int i = 1; i <= n; i++) {
            if (Arrays.binarySearch(left, i) < 0) {
                right[j++] = i;
            }
        }
        if (!check(h, left, 1)) {
            return new Outcome(Type.WA, "Non increasing sequence of heights of left soldiers");
        }
        if (!check(h, right, -1)) {
            return new Outcome(Type.WA, "Non decreasing sequence of heights of right soldiers");
        }
        if (jans.equals(IMPOSSIBLE)) {
            return new Outcome(Type.FAIL, "Contestant found solution, but jury did not!");
        }
        return new Outcome(Type.OK, "Well done: " + k + " to left, " + (n - k) + " to right");
    }

    boolean check(int[] h, int[] a, int sign) {
        for (int i = 1; i < a.length; i++) {
            if (sign * h[a[i - 1] - 1] >= sign * h[a[i] - 1]) {
                return false;
            }
        }
        return true;
    }

}
