import sys input = lambda: sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) t = int(input()) for i in range(t): x,y,d = input().split() x,y = int(x), int(y) x2,y2,d2 = input().split() x2,y2 = int(x2), int(y2) if d in "RL" and d2 in "RL": # 横方向での衝突を考える if y != y2: print("No") elif x < x2: # a -> <- b の場合のみ衝突 if d == "R" and d2 == "L": print("Yes") else: print("No") else: # b -> <- a の場合のみ衝突 if d == "L" and d2 == "R": print("Yes") else: print("No") continue if d in "UD" and d2 in "UD": # 縦方向での衝突を考える if x != x2: print("No") elif y < y2: # ^ v の場合のみ衝突 if d == "U" and d2 == "D": print("Yes") else: print("No") else: # v ^ の場合のみ衝突 if d == "D" and d2 == "U": print("Yes") else: print("No") continue if d2 in "UD": # d1がUD、d2がRLになるように入れ替える x, y, d, x2, y2, d2 = x2, y2, d2, x, y, d # 衝突予想地点 sx, sy = x, y2 # ここを通るかどうかを確認する if not ((d == "U" and y < sy) or (d == "D" and y > sy)): # aが通らない print("No") continue if not ((d2 == "R" and x2 < sx) or (d2 == "L" and x2 > sx)): # bが通らない print("No") continue # 到着予想時刻の計算 yosou_a = abs(sy-y) yosou_b = abs(sx-x2) if yosou_a == yosou_b: print("Yes") else: print("No")