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) {
        inf.nextToken();
        int n = inf.nextInt();

        int jk = ans.nextInt();
        int pk = ouf.nextInt();

        String wa = null;
        for (int i = 0; i < pk; i++) {
            String jc = i < jk ? ans.nextToken() : "";
            String pc = ouf.nextToken();
            if (!jc.equals(pc))
                wa = String.format("Expected code '%s', found '%s'", jc, pc);
        }

        if (!ouf.seekEoF())
            throw new Outcome(PE, "Extra data in output file");

        if (wa != null)
            return new Outcome(WA, wa);
        if (jk != pk)
            return new Outcome(WA, String.format("Expected %d codes, found %d", jk, pk));

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