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

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

	@Override
	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		int n = inf.nextInt();
		int m = inf.nextInt();
		char[][] c = new char[n][];
		for (int i = 0; i < n; i++) {
			c[i] = inf.nextToken().toCharArray();
		}
		int ja = ans.nextInt();
		int pa = ouf.nextInt();
		if (pa > ja) {
			return new Outcome(Type.WA,
					"Participant didn't find an optimal solution");
		}
		for (int i = 0; i < pa; i++) {
			int type = ouf.nextInt();
			if (type != 1 && type != 2) {
				return new Outcome(Type.WA, "No such type of diagonal as "
						+ type + " line #" + (i + 1));
			}
			int x = ouf.nextInt();
			int y = ouf.nextInt();
			if (x < 1 || x > n) {
				return new Outcome(Type.WA, "Row number must be in range [1, "
						+ n + "], found " + x + " on line #" + (i + 1));
			}
			if (y < 1 || y > m) {
				return new Outcome(Type.WA,
						"Column number must be in range [1, " + m
								+ "], found " + y + " on line #" + (i + 1));
			}
			String op = ouf.nextToken();
			if (!op.equals("W") && !op.equals("B")) {
				return new Outcome(Type.WA,
						"Color must be \"W\" or \"B\" found " + op
								+ " on line #" + (i + 1));
			}
			--x;
			--y;
			if (type == 1) {
				int sum = x + y;
				for (int cx = 0; cx < n; cx++) {
					int cy = sum - cx;
					if (cy < 0 || cy >= m) {
						continue;
					}
					c[cx][cy] = op.charAt(0);
				}
			} else {
				int dif = x - y;
				for (int cx = 0; cx < n; cx++) {
					int cy = cx - dif;
					if (cy < 0 || cy >= m) {
						continue;
					}
					c[cx][cy] = op.charAt(0);
				}
			}
		}
		boolean isChessBoard = false;
		for (int color = 0; color < 2; color++) {
			boolean ok = true;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					ok &= "WB".indexOf(c[i][j]) == ((i ^ j ^ color) & 1);
				}
			}
			isChessBoard |= ok;
		}
		if (!isChessBoard) {
			return new Outcome(Type.WA,
					"Participant's painting didn't result with chessboard");
		}
		if (ja > pa) {
			return new Outcome(Type.FAIL,
					"Unbelievable, participant found better answer");
		}
		return new Outcome(Type.OK, "OK, Participant did a good job");
	}
}
