N=int(input()) for tests in range(N): A0,W0,T0,M0,O0,R0=map(int,input().split()) A1,W1,T1,M1,O1,R1=map(int,input().split()) X=input() r=A0-A1 if r<0: print("No") continue if X=="WA" and W0==0 and r+W0+T0+M0+O0+R0==W1: print("Yes") elif X=="TLE" and T0==0 and r+W0+T0+M0+O0+R0==T1: print("Yes") elif X=="MLE" and M0==0 and r+W0+T0+M0+O0+R0==M1: print("Yes") elif X=="OLE" and O0==0 and r+W0+T0+M0+O0+R0==O1: print("Yes") elif X=="RE" and R0==0 and r+W0+T0+M0+O0+R0==R1: print("Yes") else: print("No")