//#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } constexpr ll mod=1e9+7; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; map mp; mp["WA"]=1; mp["TLE"]=2; mp["MLE"]=3; mp["OLE"]=4; mp["RE"]=5; while(q--){ vector a(6),b(6); for(int i=0;i<6;i++){ cin >> a[i]; } for(int i=0;i<6;i++){ cin >> b[i]; } string s; cin >> s; int id=mp[s]; bool ok=true; if(a[id]>0)ok=false; for(int i=1;i<6;i++){ if(i==id)continue; if(b[i]>0)ok=false; } if(ok)printf("Yes\n"); else printf("No\n"); } }