T=int(input()) for _ in range(T): x1,y1,d1=input().split() x1=int(x1) y1=int(y1) x2,y2,d2=input().split() x2=int(x2) y2=int(y2) f=0 if x1==x2: if y1y2: f|=d1=="D" and d2=="U" elif y1==y2: if x1x2: f|=d1=="L" and d2=="R" elif abs(x1-x2)==abs(y1-y2): if x1y2: f|=d1=="D" and d2=="L" f|=d1=="R" and d2=="U" if x1>x2 and y1x2 and y1>y2: f|=d1=="U" and d2=="R" f|=d1=="L" and d2=="U" print(["No","Yes"][f])