N=int(input()) S=['AC','WA','TLE','MLE','OLE','RE'] for i in range(N): A=list(map(int,input().split())) B=list(map(int,input().split())) X=input() Y=0 f=0 for j in range(1,len(A)): if S[j]==X: Y=A[j] Z=0 V=0 for j in range(1,len(B)): if S[j]==X: Z=B[j] else: V+=B[j] if max(A)==A[0]: print('Yes') else: if Y: print('No') elif Z-A[0]+B[0]==sum(A[1:]) and not(V): print('Yes') else: print('No')