T = int(input()) dir = { "D": (0, -1), "U": (0, 1), "L": (-1, 0), "R": (1, 0) } for _ in range(T): x1, y1, d1 = [x for x in input().split()] x2, y2, d2 = [x for x in input().split()] x1 = int(x1) y1 = int(y1) x2 = int(x2) y2 = int(y2) rx = x2 - x1 ry = y2 - y1 dx1, dy1 = dir[d1] dx2, dy2 = dir[d2] rdx = dx2 - dx1 rdy = dy2 - dy1 if rx < 0: rx = -rx rdx = -rdx if ry < 0: ry = -ry rdy = -rdy cond1 = rx == 0 and rdx == 0 and rdy < 0 cond2 = ry == 0 and rdy == 0 and rdx < 0 cond3 = (rx == ry and rdx < 0 and rdy < 0) ans = "Yes" if cond1 or cond2 or cond3 else "No" print(ans) # x2 = 3 # y2 = 2 + t # x3 = 5 - t # y3 = 4 # 2 + t == 4 # 3 == 5 - t