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("No") continue if (d=="U" and g=="D"): if b==e and f-c>0: print("Yes") else: print("No") elif (d=="D" and g=="U"): if b==e and c-f>0: print("Yes") else: print("No") elif (d=="R" and g=="L"): if c==f and e-b>0: print("Yes") else: print("No") elif (d=="L" and g=="R"): if c==f and b>e>0: 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