N = int(input()) men = {"AC": 0, "WA": 1, "TLE": 2, "MLE": 3, "OLE": 4, "RE": 5} for case in range(N): Bef = list(map(int, input().split())) Aft = list(map(int, input().split())) x = men[input()] ans = True befsum = 0 for i in range(1, 6): if i != x: if Aft[i] > 0: ans = False break befsum += Bef[i] if ans and befsum <= Aft[x]: print("Yes") else: print("No")