#include #include using namespace std; int main(){ int n; cin >> n; while(n--){ int a, w, t, m, o, r; cin >> a >> w >> t >> m >> o >> r; int a2, w2, t2, m2, o2, r2; cin >> a2 >> w2 >> t2 >> m2 >> o2 >> r2; string x; cin >> x; int outcase = w+t+o+m+r; int afteroutcase = w2+t2+o2+m2+r2; if(x == "WA"){ if(outcase <= w2 && outcase <= afteroutcase && w2 == afteroutcase && w == 0) cout << "Yes" << endl; else cout << "No" << endl; }else if(x == "TLE"){ if(outcase <= t2 && outcase <= afteroutcase && t2 == afteroutcase && t == 0) cout << "Yes" << endl; else cout << "No" << endl; }else if(x == "MLE"){ if(outcase <= m2 && outcase <= afteroutcase && m2 == afteroutcase && m == 0) cout << "Yes" << endl; else cout << "No" << endl; }else if(x == "OLE"){ if(outcase <= o2 && outcase <= afteroutcase && o2 == afteroutcase && o == 0) cout << "Yes" << endl; else cout << "No" << endl; }else{ if(outcase <= r2 && outcase <= afteroutcase && r2 == afteroutcase && r == 0) cout << "Yes" << endl; else cout << "No" << endl; } } return 0; }