Q=int(input()) for _ in range(Q): x1,y1,d1=input().split() x2,y2,d2=input().split() x1=int(x1) x2=int(x2) y1=int(y1) y2=int(y2) if d1==d2: print('No') continue if (d1=='R' and d2=='L') or (d1=='L' and d2=='R'): if y1!=y2: print('No') continue if d1=='R': z=1 else: z=-1 time=(x2-x1)//z if time>0: print('Yes') else: print('No') elif (d1=='U' and d2=='D') or (d1=='D' and d2=='U'): if x1!=x2: print('No') continue if d1=='U': z=1 else: z=-1 time=(y2-y1)//z if time>0: print('Yes') else: print('No') elif d1=='R' or d1=='L': x3,y3=x2,y1 if d1=='R': z=1 else: z=-1 time1=(x3-x1)//z if d2=='U': z=1 else: z=-1 time2=(y2-y3)//z if time1!=time2: print('No') else: if time1>0: print('Yes') else: print('No') else: x3,y3=x1,y2 if d1=='U': z=1 else: z=-1 time1=(y3-y1)//z if d2=='R': z=1 else: z=-1 time2=(x3-x2)//z if time1!=time2: print('No') else: if time1>0: print('Yes') else: print('No')