#!/usr/bin/env python3 # # No.1317 月曜日の朝、WAを出した # import sys, os, math def read_ints(): return list(map(int, input().split())) m = dict((x, i) for i, x in enumerate('AC WA TLE MLE OLE RE'.split())) T = int(input()) for _ in range(T): a = read_ints() b = read_ints() x = input() ans = True if sum(a) != sum(b): ans = False else: if b[m[x]] - a[m[x]] <= 0: ans = False print("Yes" if ans else "No")