import sys from collections import deque,defaultdict import itertools import heapq import bisect import math #sys.setrecursionlimit(10 ** 9) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) ml = lambda: map(str, input().split()) li = lambda: list(mi()) li_st = lambda: list(map(str, input().split())) lli = lambda n: [li() for _ in range(n)] mod = 998244353 T = ii() def check(x,y,d,xx,yy): if d == "U": if yy >= y: y += yy - y else: return x,y,False elif d == "D": if y >= yy: y -= y - yy else: return x,y,False elif d == "L": if x >= xx: x -= x - xx else: return x,y,False else: if xx >= x: x += xx - x else: return x,y,False return x,y,True for i in range(T): x1,y1,d1 = ml() x2,y2,d2 = ml() x1,y1 = int(x1),int(y1) x2,y2 = int(x2),int(y2) ans = set() x,y,flag1 = check(x1,y1,d1,x2,y2) xx,yy,flag2 = check(x2,y2,d2,x1,y1) if flag1 and flag2: ans.add((x,y)) ans.add((xx,yy)) if len(ans) == 1: print("Yes") else: n = set() n.add(d1) n.add(d2) if len(n) == 1: print("No") else: if n == {"U","D"}: if x == xx: print("Yes") else: print("No") elif n == {"R","L"}: if y == yy: print("Yes") else: print("No") else: print("No") else: print("No")