import java.util.*; import java.io.*; class Main{ private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static final PrintWriter out = new PrintWriter(System.out); public static void main(String[] args)throws IOException{ int T = Integer.parseInt(br.readLine()); while(T-->0){ String[] str; str = br.readLine().split(" "); int x1 = Integer.parseInt(str[0]); int y1 = Integer.parseInt(str[1]); char d1 = str[2].charAt(0); str = br.readLine().split(" "); int x2 = Integer.parseInt(str[0]); int y2 = Integer.parseInt(str[1]); char d2 = str[2].charAt(0); if(x1==x2){ if(y1y3&&d2=='D') out.println( x3-x1==y2-y3?"Yes":"No"); else out.println("No"); } else if(x3y3&&d2=='D') out.println( x1-x3==y2-y3?"Yes":"No"); else out.println("No"); } else if(y1x3&&d2=='L') out.println( x2-x3==y3-y1?"Yes":"No"); else out.println("No"); } else if(y1>y3&&d1=='D'){ if(x2x3&&d2=='L') out.println( x2-x3==y1-y3?"Yes":"No"); else out.println("No"); } else out.println("No"); } } } br.close(); out.close(); } }