import java.util.*;

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 {
	@Override
	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		int n = inf.nextInt();
		inf.skipLine();
		int jAns = ans.nextInt();
		int cAns = ouf.nextInt();
		if (cAns < 0) {
			return new Outcome(PE, "@Checker: Negative number of messages: " + cAns);
		}
		if (cAns > n) {
			return new Outcome(PE, "@Checker: Too many messages: " + cAns);
		}
		int[] indices = new int[cAns];
		for (int i = 0; i < cAns; i++) {
			indices[i] = ouf.nextInt();
			if (indices[i] < 1 || indices[i] > n) {
				return new Outcome(PE, "@Checker: Invalid message index: " + indices[i]);
			}
			if (i > 0 && indices[i - 1] >= indices[i]) {
				return new Outcome(PE, "@Checker: Non-increasing indices " + indices[i - 1] + " " + indices[i]);
			}
		}
		if (!ouf.seekEoF())
			throw new Outcome(PE, "Extra data in output file");

		// PE check done, check for WA

		String prev = null;
		for (int i = 1, j = 0; i <= n && j < cAns; i++) {
			String s = inf.nextLine();
			if (i != indices[j]) {
				continue;
			}
			int colonIndex = s.indexOf(':');
			String handle = s.substring(0, colonIndex);
			if (handle.equals(prev)) {
				return new Outcome(WA, "@Checker: Self-mentions aren't allowed: " + indices[j - 1] + " " + indices[j]);
			}
			s = s.substring(colonIndex + 2);
			StringTokenizer st = new StringTokenizer(s);
			boolean ok = (j == 0);
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(prev)) {
					ok = true;
				}
			}
			if (!ok) {
				return new Outcome(WA, "@Checker: No mention of previous handle: " + indices[j - 1] + " " + indices[j]);
			}
			prev = handle;
			j++;
		}
		if (cAns > jAns) {
			return new Outcome(FAIL, "Better than jury's: " + cAns + " > " + jAns);
		}
		if (cAns < jAns) {
			return new Outcome(WA, "@Checker: The conversation is not longest: " + cAns + " < " + jAns);
		}
		return new Outcome(OK, "@Checker: " + cAns + " messages #correct");
	}
}
