not_AC_dict = {'WA' : 1, 'TLE' : 2, 'MLE' : 3, 'OLE' :4, 'RE' :5} t = int(input()) for i in range(t): a = [int (v) for v in input().split()] b = [int (v) for v in input().split()] s = input() ans = [] for j in range(6): if j == 0: ans.append(a[j] >= b[j]) elif j != not_AC_dict[s]: ans.append(b[j] == 0) # print(ans) print("Yes") if all(ans) else print("No")