def solve(x1,y1,d1, x2,y2,d2): if d1==d2: return False if d1=='R': if d2=='L': return y1==y2 and x1 < x2 elif d2=='U': return y1 > y2 and x2-x1 == y1-y2 else: return y1 < y2 and x2-x1 == y2-y1 elif d1=='L': if d2=='R': return y1==y2 and x1 > x2 elif d2=='U': return y1 > y2 and x2-x1 == y2-y1 else: return y1 < y2 and x2-x1 == y1-y2 elif d1=='U': if d2=='D': return x1==x2 and y1 < y2 elif d2=='R': return y1 < y2 and x1-x2 == y2-y1 else: return y1 < y2 and x2-x1 == y2-y1 else: if d2=='U': return x1==x2 and y1 > y2 elif d2=='R': return y1 > y2 and x1-x2 == y1-y2 else: return y1 > y2 and x2-x1 == y1-y2 T = int(input()) for _ in range(T): x1,y1,d1 = input().split() x2,y2,d2 = input().split() print('Yes' if solve(int(x1), int(y1), d1, int(x2), int(y2), d2) else 'No')