t = int(input()) for _ in range(t): x1, y1, d1 = map(str, input().split()) x2, y2, d2 = map(str, input().split()) x1, y1 = int(x1), int(y1) x2, y2 = int(x2), int(y2) if (d1=="U" or d1=="D") and (d2=="U" or d2=="D"): if x1!=x2: print('No'); continue if (d1=="L" or d1=="R") and (d2=="L" or d2=="R"): if y1!=y2: print('No'); continue if x1==x2: if (d1=="U" and d2=="D"): if y1y2: print('Yes'); continue else: print('No'); continue else: print('No'); continue elif y1==y2: if (d1=="L" and d2=="R"): if x1>x2: print('Yes'); continue else: print('No'); continue elif (d1=="R" and d2=="L"): if x1y2: print('No'); f=False else: t1=y2-y1 elif d1=="D": if y1x2: print('No'); f=False else: t1=x2-x1 if f: if d2=="U": if y1y2: print('No'); f=False else: t2=y2-y1 elif d2=="L": if x1>x2: print('No'); f=False else: t2=x2-x1 else: if x1