// Arup Guha
// 2/22/2014
// Verifier for 2013 Greater NY Regional Problem F: Chomp

import java.util.*;
import java.io.*;

public class check_chomp {

	final public static int MAX = 100;

	public static void main(String[] args) {

		// Here is our memo array.
		boolean[][][] ans = new boolean[MAX+1][MAX+1][MAX+1];

		// Go through each possible call.
		for (int small=0; small<=MAX; small++) {
			for (int mid=small; mid<=MAX; mid++) {
				for (int big=mid; big<=MAX; big++) {

					// Special case.
					if (small == 0 && mid == 0) {
						if (big == 0) ans[small][mid][big] = true;
						if (big > 1) ans[small][mid][big] = true;
					}

					// Build off old cases.
					else {

						boolean best = false;

						// Try to win in row 3.
						for (int col=small-1; col>=0; col--)
							if (ans[col][mid][big] == false)
								best = true;

						// If you didn't, try to win in row 2.

						for (int col=mid-1; col>=0; col--)
							if (ans[Math.min(small,col)][col][big] == false)
								best = true;

						// Then row 1...

						for (int col=big-1; col>=0; col--)
							if (ans[Math.min(small,col)][Math.min(mid,col)][col] == false)
								best = true;

						ans[small][mid][big] = best;

					}

				}
			}
		} // end small.

		Scanner stdin = null;
		Scanner output = null;
		int numCases = 0;

		try {

			stdin = new Scanner(new File(args[0]));
			numCases = stdin.nextInt();
			output = new Scanner(new File(args[1]));
		}
		catch (FileNotFoundException e) {
			System.out.println("No file found.");
			System.exit(0);
		}

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in data.
			int caseNum = stdin.nextInt();
			int big = stdin.nextInt();
			int mid = stdin.nextInt();
			int small = stdin.nextInt();

			String line = output.nextLine();
			StringTokenizer tok = new StringTokenizer(line);

			if (ans[small][mid][big]) {

				if (tok.countTokens() != 4) {
					System.out.println("Not the correct number of tokens");
					break;
				}
				String[] items = new String[4];
				for (int i=0; i<4; i++) items[i] = tok.nextToken();

				if (!items[0].equals(""+loop)) {
					System.out.println("Case number not correct.");
					break;
				}
				if (!items[1].equals("W"))	{
					System.out.println("Incorrect general result.");
					break;
				}

				int r=0, c=0;
				try {
					c = Integer.parseInt(items[2])-1;
					r = Integer.parseInt(items[3]);
				}
				catch (NumberFormatException e){
					System.out.println("Not a number...");
					break;
				}

				if (r == 1) {
					if (c < 0 || c >= big) {
						System.out.println("invalid column");
						break;
					}
					if (ans[Math.min(small,c)][Math.min(mid,c)][c]) {
						System.out.println("Not a winning move case "+loop);
						break;
					}

				}
				else if (r == 2) {
					if (c < 0 || c >= mid) {
						System.out.println("invalid column");
						break;
					}
					if (ans[Math.min(small,c)][c][big]) {
						System.out.println("Not a winning move case "+loop+" "+Math.min(small,c)+" "+c+" "+big);
						break;
					}
				}
				else if (r == 3) {
					if (c < 0 || c >= mid) {
						System.out.println("invalid column");
						break;
					}
					if (ans[c][mid][big]) {
						System.out.println("Not a winning move case "+loop);
						break;
					}
				}
				else {
					System.out.println("not a valid row.");
					break;
				}
			}
			else {
				if (tok.countTokens() != 2) {
					System.out.println("Not the correct number of tokens");
					break;
				}
				String[] items = new String[2];
				for (int i=0; i<2; i++) items[i] = tok.nextToken();

				if (!items[0].equals(""+loop)) {
					System.out.println("Case number not correct.");
					break;
				}
				if (!items[1].equals("L"))	{
					System.out.println("Incorrect general result.");
					break;
				}

			}

		}
	}
}