c = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)} for _ in range(int(input())): x1, y1, d1 = input().split() x2, y2, d2 = input().split() x1, x2, y1, y2 = int(x1), int(x2), int(y1), int(y2) if d1 == 'U' and d2 == 'D' and x1 == x2 and y1 < y2: print('Yes') elif d1 == 'D' and d2 == 'U' and x1 == x2 and y1 > y2: print('Yes') elif d1 == 'R' and d2 == 'L' and y1 == y2 and x1 < x2: print('Yes') elif d1 == 'L' and d2 == 'R' and y1 == y2 and x1 > x2: print('Yes') elif ((d1 == 'U' and d2 == 'R') or (d1 == 'L' and d2 == 'D')) and x1 - x2 == y2 - y1: print('Yes') elif ((d1 == 'U' and d2 == 'L') or (d1 == 'R' and d2 == 'D')) and x2 - x1 == y2 - y1: print('Yes') elif ((d1 == 'D' and d2 == 'R') or (d1 == 'L' and d2 == 'U')) and x1 - x2 == y1 - y2: print('Yes') elif ((d1 == 'D' and d2 == 'L') or (d1 == 'R' and d2 == 'U')) and x2 - x1 == y1 - y2: print('Yes') else: print('No')