X=['AC','WA','TLE','MLE','OLE','RE'] def solve(): global X a=list(map(int,input().split())) b=list(map(int,input().split())) k=X.index(input()) if b[k]==0: return 'No' if a[k]!=0: return 'No' if sum(a[1:])>b[k]: return 'No' return 'Yes' for _ in [0]*int(input()): print(solve())