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

import static ru.ifmo.testlib.Outcome.Type.*;

public class Check implements Checker {

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        int n = inf.nextInt();
        boolean[] ja = readAnswer(n, ans, FAIL);
        boolean[] pa = readAnswer(n, ouf, WA);

        int c = 0;
        for (int i = 0; i < n; i++) {
            if (ja[i] != pa[i]) {
                if (ja[i]) {
                    return new Outcome(WA, String.format("Winning move to %d missed", i + 1));
                } else {
                    return new Outcome(WA, String.format("Not winning move to %d", i + 1));
                }
            }
            if (ja[i]) {
                c++;
            }
        }

        return new Outcome(OK, String.format("%d of %d", c, n));
    }

    private boolean[] readAnswer(int n, InStream ouf, Outcome.Type type) {
        int m = ouf.nextInt();
        if (m < 0 || n < m) {
            throw new Outcome(type, String.format("Invalid number of moves: %d", m));
        }

        boolean[] result = new boolean[n];
        for (int i = 0; i < m; i++) {
            int move = ouf.nextInt() - 1;
            if (move < 0 || n <= move) {
                throw new Outcome(type, String.format("Invalid move %d", move + 1));
            }
            if (result[move]) {
                throw new Outcome(type, String.format("Duplicate move %d", move + 1));
            }
            result[move] = true;
        }
        if (!ouf.seekEoF())
            throw new Outcome(type, "Extra data in file");
        return result;
    }
}
