import java.math.BigInteger;
import java.util.HashSet;

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

public class Check implements Checker {
    int a, b;
    int red, green, blue;

    @Override
    public Outcome test(InStream inf, InStream ouf, InStream ans) {
	int tests = inf.nextInt(), test = 0;
	HashSet<String> hs = new HashSet<>();
	hs.add("RED");
	hs.add("BLUE");
	hs.add("GREEN");
	while (test < tests) {
	    test++;
	    a = inf.nextInt();
	    b = inf.nextInt();
	    red = inf.nextInt();
	    green = inf.nextInt();
	    blue = inf.nextInt();
	    String jAns = ans.nextToken().toUpperCase();
	    String pAns = ouf.nextToken().toUpperCase();
	    if (!hs.contains(pAns))
		return new Outcome(Type.PE, "Incorrect string.");
	    if (!hs.contains(jAns))
		return new Outcome(Type.FAIL, "Incorrect string.");
	    int jAnswer = calc(jAns);
	    int pAnswer = calc(pAns);
	    if (pAnswer < jAnswer)
		return new Outcome(Type.WA, "Jury has better");
	    if (pAnswer > jAnswer)
		return new Outcome(Type.FAIL, "Participant has better");
	}
	return new Outcome(Type.OK, "OK");
    }

    int calc(String s) {
	if (s.equals("RED"))
	    return calc(a, b, red + 1, green, blue);
	if (s.equals("BLUE"))
	    return calc(a, b, red, green, blue + 1);
	if (s.equals("GREEN"))
	    return calc(a, b, red, green + 1, blue);
	return -1;
    }

    int calc(int a, int b, int red, int green, int blue) {
	return a * (red * red + green * green + blue * blue) + b
		* Math.min(red, Math.min(green, blue));
    }
}
