import sys #sys.setrecursionlimit(10 ** 6) INF = float('inf') MOD = 10**9 + 7 MOD2 = 998244353 from collections import defaultdict def ceil(A,B): return -(-A//B) def line_cross_point(P0, P1, Q0, Q1): x0, y0 = P0; x1, y1 = P1 x2, y2 = Q0; x3, y3 = Q1 a0 = x1 - x0; b0 = y1 - y0 a2 = x3 - x2; b2 = y3 - y2 d = a0*b2 - a2*b0 if d == 0: return None sn = b2 * (x2-x0) - a2 * (y2-y0) s = sn // d tn = b0 * (x2-x0) - a0 * (y2-y0) t = tn//d return s,t """ 2 1 1 U 1 5 D 1 1 U 1 5 U """ def solve(): def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LC(): return list(sys.stdin.readline().rstrip()) def IC(): return [int(c) for c in sys.stdin.readline().rstrip()] def MI(): return map(int, sys.stdin.readline().split()) T = int(input()) D = {"D":(0,-1),"U":(0,1),"L":(-1,0),"R":(1,0)} for test in range(T): X1,Y1,D1 = input().split() X1 = int(X1) Y1 = int(Y1) P0 = (X1,Y1) P1 = (X1+D[D1][0],Y1+D[D1][1]) X2, Y2, D2 = input().split() X2 = int(X2) Y2 = int(Y2) Q0 = (X2,Y2) Q1 = (X2+D[D2][0],Y2+D[D2][1]) #print(P0,P1,Q0,Q1) C = line_cross_point(P0, P1, Q0, Q1) if (D1 == D2): print("No") elif(C==None):#並行 if(X1==X2 or Y1==Y2): D0 = abs(X1-X2)+abs(Y1-Y2) D1 = abs(P1[0]-Q1[0])+abs(P1[1]-Q1[1]) if(D1