T=int(input()) for _ in range(T): x1,y1,d1=map(str,input().split()) x2,y2,d2=map(str,input().split()) x1=int(x1) x2=int(x2) y1=int(y1) y2=int(y2) if {d1,d2} == {'U','D'}: if x1==x2 and ((y1>=y2 and d1=='D') or (y2>=y1 and d1=='U')): print('Yes') else: print('No') elif {d1,d2} == {'L','R'}: if y1==y2 and ((x1>=x2 and d1=='L') or (x2>=x1 and d1=='R')): print('Yes') else: print('No') else: if d1=='U' or d1=='D': x1,y1,d1,x2,y2,d2=x2,y2,d2,x1,y1,d1 if d1 =='L': if d2=='U' and (x1-x2)>0 and (x1-x2)==(y1-y2): print('Yes') elif d2=='D' and (x1-x2)>0 and (x1-x2)==(y2-y1): print('Yes') else: print('No') elif d1=='R': if d2=='U' and (x2-x1)>0 and (x2-x1)==(y1-y2): print('Yes') elif d2=='D' and (x2-x1)>0 and (x2-x1)==(y2-y1): print('Yes') else: print('No') else: print('No')