def manh_check(x1, y1, x2, y2): if abs(x1 - x2) == abs(y1 - y2): return True else: return False def direction(x1, y1, x2, y2): # (x1, y1)は(x2, y2)よりもなんなのか? if x1 < x2 and y1 > y2: return "hidariue" elif x1 < x2 and y1 < y2: return "hidarisita" elif x1 > x2 and y1> y2: return "migiue" elif x1 > x2 and y1 < y2: return "migisita" else: return "None" T = int(input()) for _ in range(T): x1, y1, D1 = input().split() x2, y2, D2 = input().split() x1 = int(x1) x2 = int(x2) y1 = int(y1) y2 = int(y2) if D1 == D2: print("No") continue Flg = False if D1 == "U" and D2 == "R": if direction(x2, y2, x1, y1) == "hidariue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "R" and D2 == "U": if direction(x2, y2, x1, y1) == "migisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "U" and D2 == "L": if direction(x2, y2, x1, y1) == "migiue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "L" and D2 == "U": if direction(x2, y2, x1, y1) == "hidarisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "U" and D2 == "D": if x1 == x2 and y2 > y1: Flg = True elif D1 == "D" and D2 == "U": if x1 == x2 and y2 < y1: Flg = True elif D1 == "D" and D2 == "R": if direction(x2, y2, x1, y1) == "hidarisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "R" and D2 == "D": if direction(x2, y2, x1, y1) == "migiue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "D" and D2 == "L": if direction(x2, y2, x1, y1) == "migisita" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "L" and D2 == "D": if direction(x2, y2, x1, y1) == "hidariue" and manh_check(x1, y1, x2, y2): Flg = True elif D1 == "R" and D2 == "L": if y1 == y2 and x1 < x2: Flg = True elif D1 == "L" and D2 == "R": if y1 == y2 and x1 > x2: Flg = True if Flg: print("Yes") else: print("No")