#include using namespace std; int N; int A[6],B[6]; main() { cin>>N; for(;N--;) { for(int i=0;i<6;i++)cin>>A[i]; for(int i=0;i<6;i++)cin>>B[i]; string x;cin>>x; int id; if(x=="WA")id=1; else if(x=="TLE")id=2; else if(x=="MLE")id=3; else if(x=="OLE")id=4; else if(x=="RE")id=5; int sum=B[1]+B[2]+B[3]+B[4]+B[5]; cout<<(A[id]==0&&B[id]==sum?"Yes":"No")<