#include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; int to_idx(string s){ if(s == "AC") return 0; if(s == "WA") return 1; if(s == "TLE") return 2; if(s == "MLE") return 3; if(s == "OLE") return 4; if(s == "RE") return 5; } void solve(){ int cnt[2][6]; for(int i = 0; i < 2; i++){ for(int j = 0; j < 6; j++){ cin >> cnt[i][j]; } } string x; cin >> x; int idx = to_idx(x); if(cnt[0][idx] != 0){ cout << "No" << endl; return; } for(int i = 1; i <= 5; i++){ if(i != idx && cnt[1][i] != 0){ cout << "No" << endl; return; } } if(cnt[1][0] <= cnt[0][0]){ cout << "Yes" << endl; }else{ cout << "No" << endl; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n; cin >> n; for(int i = 0; i < n; i++) solve(); }