#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int T; cin >> T; rep(_,T) { vector A(6), B(6); rep(i,6) cin >> A[i]; rep(i,6) cin >> B[i]; string S; cin >> S; vector C = {"AC", "WA", "TLE", "MLE", "OLE", "RE"}; int I = -1; rep(i,6) if(S == C[i]) I = i; int ok = 1; ok &= A[I] == 0; rep(i,6) if(i != I) ok &= B[i] == 0; cout << (ok ? "Yes" : "No") << "\n"; } }