for _ in range(int(input())): x1, y1, d1 = input().split() x1, y1 = map(int, (x1, y1)) x2, y2, d2 = input().split() x2, y2 = map(int, (x2, y2)) d = d1 + d2 x2 -= x1 y2 -= y1 ok = False if x2 == 0: if y2 > 0 and d == "UD": ok = True if y2 < 0 and d == "DU": ok = True if y2 == 0: if x2 > 0 and d == "RL": ok = True if x2 < 0 and d == "LR": ok = True if x2 == y2: if x2 > 0 and (d == "UL" or d == "RD"): ok = True if x2 < 0 and (d == "DR" or d == "LU"): ok = True if x2 == -y2: if x2 > 0 and (d == "DL" or d == "RU"): ok = True if x2 < 0 and (d == "UR" or d == "LD"): ok = True print("Yes" if ok else "No")