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 for i in range(6): if judges[i] == x and sum(a) - b[0] == b[i] and a[i] == 0: print("Yes") break else: print("No")