class Input_kyopro: def II(self): return int(input()) def MI(self): return map(int,input().split()) def MS(self): return map(str,input().split()) def LMI(self): return list(self.MI()) def LMS(self): return list(self.MS()) def LLI(self,N): return [self.LMI() for _ in range(N)] def LLS(self,N): return [self.LMS() for _ in range(N)] def LS(self,N): return [input() for _ in range(N)] def LSL(self,N): return [list(input()) for _ in range(N)] def LI(self,N): return [self.II() for _ in range(N)] I=Input_kyopro() #入力 T=I.II() for _ in range(T): x0,y0,d0=I.MS() x1,y1,d1=I.MS() x0=int(x0) y0=int(y0) x1=int(x1) y1=int(y1) if d0==d1: print('No') elif d0=='U': if d1=='D' and x0==x1 and y00 and x1-x0==y1-y0: print('Yes') else: print('No') elif d1=='R': if x0-x1>0 and x0-x1==y1-y0: print('Yes') else: print('No') else: print('No') elif d0=='D': if d1=='U' and x0==x1 and y0>y1: print('Yes') elif d1=='L': if x1-x0>0 and x1-x0==y0-y1: print('Yes') else: print('No') elif d1=='R': if x0-x1>0 and x0-x1==y0-y1: print('Yes') else: print('No') else: print('No') elif d0=='R': if d1=='L' and y0==y1 and x00 and y1-y0==x1-x0: print('Yes') else: print('No') elif d1=='U': if y0-y1>0 and y0-y1==x1-x0: print('Yes') else: print('No') else: print('No') elif d0=='L': if d1=='R' and y0==y1 and x0>x1: print('Yes') elif d1=='D': if y1-y0>0 and y1-y0==x0-x1: print('Yes') else: print('No') elif d1=='U': if y0-y1>0 and y0-y1==x0-x1: print('Yes') else: print('No') else: print('No')