a=int(input()) for i in range(a): b,c,d=input().split() b,c=int(b),int(c) e,f,g=input().split() e,f=int(e),int(f) if d==g: print("Yes") continue if (d=="U" and g=="D") or (d=="D" and g=="U"): if b==e: print("Yes") else: print("No") elif (d=="R" and g=="L") or (d=="L" and g=="R"): if c==f: print("Yes") else: print("No") elif (d=="U" and g=="L"): if e-b==f-c and e-b>0 and f-c>0: print("Yes") else: print("No") elif (d=="L" and g=="U"): if e-b==f-c and b-e>0 and c-f>0: print("Yes") else: print("No") elif (d=="U" and g=="R"): if e-b==c-f and b-e>0 and f-c>0: print("Yes") else: print("No") elif (d=="R" and g=="U"): if b-e==c-f and e-b>0 and c-f>0: print("Yes") else: print("No") elif (d=="R" and g=="D"): if e-b==f-c and e-b>0 and f-c>0: print("Yes") else: print("No") elif (d=="D" and g=="R"): if b-e==c-f and b-e>0 and c-f>0: print("Yes") else: print("No") elif (d=="D" and g=="L"): if e-b==c-f and e-b>0 and c-f>0: print("Yes") else: print("No") elif (d=="L" and g=="D"): if b-e==f-c and b-e>0 and c-c>0: print("Yes") else: print("No") else: a=a