using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new bool[t]; for (var u = 0; u < t; ++u) { var c1 = ReadLine().Split(); var c2 = ReadLine().Split(); var x1 = int.Parse(c1[0]); var y1 = int.Parse(c1[1]); var x2 = int.Parse(c2[0]); var y2 = int.Parse(c2[1]); ans[u] = (c1[2] == "U" && c2[2] == "D" && x1 == x2 && y1 < y2) || (c1[2] == "D" && c2[2] == "U" && x1 == x2 && y1 > y2) || (c1[2] == "L" && c2[2] == "R" && x1 > x2 && y1 == y2) || (c1[2] == "R" && c2[2] == "L" && x1 < x2 && y1 == y2) || (c1[2] == "U" && c2[2] == "L" && x1 < x2 && x2 - x1 == y2 - y1) || (c1[2] == "U" && c2[2] == "R" && x1 > x2 && x1 - x2 == y2 - y1) || (c1[2] == "D" && c2[2] == "L" && x1 < x2 && x2 - x1 == y1 - y2) || (c1[2] == "D" && c2[2] == "R" && x1 > x2 && x1 - x2 == y1 - y2) || (c1[2] == "L" && c2[2] == "U" && x1 > x2 && x1 - x2 == y1 - y2) || (c1[2] == "L" && c2[2] == "D" && x1 > x2 && x1 - x2 == y2 - y1) || (c1[2] == "R" && c2[2] == "U" && x1 < x2 && x2 - x1 == y1 - y2) || (c1[2] == "R" && c2[2] == "D" && x1 < x2 && x2 - x1 == y2 - y1); } WriteLine(string.Join("\n", ans.Select(f => f ? "Yes" : "No"))); } static bool Cross(int[] a, int[] b, int[] c, int[] d) { var sa = AreaSign(c, d, a); var sb = AreaSign(c, d, b); var sc = AreaSign(a, b, c); var sd = AreaSign(a, b, d); if (sa == 0 && sb == 0 && sc == 0 && sd == 0) { if (a[0] == b[0]) { var min1 = Math.Min(a[1], b[1]); var max1 = Math.Max(a[1], b[1]); var min2 = Math.Min(c[1], d[1]); var max2 = Math.Max(c[1], d[1]); return min1 <= max2 && min2 <= max1; } else { var min1 = Math.Min(a[0], b[0]); var max1 = Math.Max(a[0], b[0]); var min2 = Math.Min(c[0], d[0]); var max2 = Math.Max(c[0], d[0]); return min1 <= max2 && min2 <= max1; } } return sa != sb && sc != sd; } static int AreaSign(int[] a, int[] b, int[] c) { if (a[0] == b[0]) { if (c[0] == a[0]) return 0; else if (c[0] > a[0]) return 1; else return -1; } if (a[0] > b[0]) (a, b) = (b, a); var res = Area2(a, c) + Area2(c, b) - Area2(a, b); if (res == 0) return 0; if (res > 0) return 1; return -1; } static long Area2(int[] a, int[] b) { return (long)(a[1] + b[1]) * (b[0] - a[0]); } }