############################################################# import sys sys.setrecursionlimit(10**7) from heapq import heappop,heappush from collections import deque,defaultdict,Counter from bisect import bisect_left, bisect_right from itertools import product,combinations,permutations from math import sin,cos #from math import isqrt #DO NOT USE PyPy ipt = sys.stdin.readline iin = lambda :int(ipt()) lmin = lambda :list(map(int,ipt().split())) ############################################################# direc = {"U":0,"D":2,"R":1,"L":3} for _ in range(iin()): i1 = input().split() i2 = input().split() x1,y1,d1 = int(i1[0]),int(i1[1]),direc[i1[2]] x2,y2,d2 = int(i2[0]),int(i2[1]),direc[i2[2]] if d1 == d2: print("No") continue if d1%2 == 0 and d2%2 == 0: if x1 == x2: if d1 == 0: if y1 < y2: print("Yes") else: print("No") else: if y1 > y2: print("Yes") else: print("No") else: print("No") elif d1%2 == 1 and d2%2 == 1: if y1 == y2: if d1 == 1: if x1 < x2: print("Yes") else: print("No") else: if x1 > x2: print("Yes") else: print("No") else: print("No") else: dx = x1-x2 dy = y1-y2 if dx == dy: if x1 > x2: x1,y1,d1,x2,y2,d2 = x2,y2,d2,x1,y1,d1 if d1^d2 == 3: print("Yes") else: print("No") elif dx == -dy: if x1 > x2: x1,y1,d1,x2,y2,d2 = x2,y2,d2,x1,y1,d1 if d1^d2 == 1: print("Yes") else: print("No") else: print("No")