N = int(input()) for _ in range(N): A, W, T, M, O, R = map(int, input().split()) A_, W_, T_, M_, O_, R_ = map(int, input().split()) X = input() if X=="WA": if T_ + M_ + O_ + R_ == 0: if A>=A_: print("Yes") else: print("No") else: print("No") elif X=="TLE": if W_ + M_ + O_ + R_ == 0: if A>=A_: print("Yes") else: print("No") else: print("No") elif X=="MLE": if W_ + T_ + O_ + R_ == 0: if A>=A_: print("Yes") else: print("No") else: print("No") elif X=="OLE": if W_ + T_ + M_ + R_ == 0: if A>=A_: print("Yes") else: print("No") else: print("No") elif X=="RE": if W_ + T_ + M_ + O_ == 0: if A>=A_: print("Yes") else: print("No") else: print("No")