import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;
import ru.ifmo.testlib.Outcome.Type;
import java.util.*;

public class Check implements ru.ifmo.testlib.Checker {

    @Override
    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        int jcnt = ans.nextInt();
        int ccnt = ouf.nextInt();

        if (ccnt != jcnt) {
            return new Outcome(Type.WA, String.format("Invalid answer. Expected %d, found %d.", jcnt, ccnt));
        }

        HashSet <String> jset = new HashSet<String>();
        for (int i = 0; i < jcnt; ++i)
        {
            String cur = ans.nextToken();
            jset.add(cur);
        }
        if (jset.size() != jcnt)
            return new Outcome(Type.FAIL, 
                String.format("Jury's answer contains %d different phone numbers instead of %d!", jset.size(), jcnt));
        HashSet <String> cset = new HashSet<String>();
        for (int i = 0; i < ccnt; ++i)
        {
            String cur = ouf.nextToken();
            if (cset.contains(cur))
                return new Outcome(Type.WA, String.format("Phone number '%s' occured in the result two times.", cur));
            cset.add(cur);
            if (!jset.contains(cur))
                return new Outcome(Type.WA, String.format("The answer cannot contain phone number '%s'.", cur));
        }
        return new Outcome(Type.OK, String.format("Ok. %d phone numbers.", jcnt));
    }
}