T = int(input()) for i in range(T): x, y, d = input().split() x, y = int(x), int(y) a, b, s = input().split() a, b = int(a), int(b) if d == 'U': if s == 'U': if x == a and y == b: print('Yes') else: print('No') elif s == 'D': if x == a and y <= b: print('Yes') else: print('No') elif s == 'R': if x-a == b-y and b-y >= 0: print('Yes') else: print('No') else: if a-x == b-y and b-y >= 0: print('Yes') else: print('No') elif d == 'D': if s == 'D': if x == a and y == b: print('Yes') else: print('No') elif s == 'U': if x == a and y >= b: print('Yes') else: print('No') elif s == 'R': if x-a == y-b and y-b >= 0: print('Yes') else: print('No') else: if a-x == y-b and b-y <= 0: print('Yes') else: print('No') elif d == 'R': if s == 'R': if x == a and y == b: print('Yes') else: print('No') elif s == 'L': if y == b and x <= a: print('Yes') else: print('No') elif s == 'U': if a-x == y-b and y-b >= 0: print('Yes') else: print('No') else: if a-x == b-y and b-y >= 0: print('Yes') else: print('No') else: if s == 'L': if x == a and y == b: print('Yes') else: print('No') elif s == 'R': if y == b and x >= a: print('Yes') else: print('No') elif s == 'U': if x-a == y-b and y-b >= 0: print('Yes') else: print('No') else: if x-a == b-y and b-y >= 0: print('Yes') else: print('No')