#yuki1317 d={'WA':1,'TLE':2,'MLE':3,'OLE':4,'RE':5} n=int(input()) for i in range(n): a=list(map(int,input().split())) b=list(map(int,input().split())) x=input() res=[] for j in range(6): if j==0: res.append(a[j]>=b[j]) elif j!=d[x]: res.append(b[j]==0) else: res.append(a[j]==0) if all(res): print('Yes') else: print('No')