import sys input = sys.stdin.readline judges = ['AC', 'WA', 'TLE', 'MLE', 'OLE', 'RE'] for _ in range(int(input())): a = list(map(int, input().split())) b = list(map(int, input().split())) x = input()[: -1] if a[0] != b[0]: print("No") continue if sum(a) - a[0] != sum(b) - b[0]: print("No") continue for i in range(6): if judges[i] == x and sum(a) - a[0] == b[i]: print("Yes") break else: print("No")