#include int main() { int n; scanf("%d", &n); int i, a[6], b[6]; char x[8]; int y; int cnt; for (; n > 0; n--) { for (i = 0; i < 6; i++) scanf("%d", &a[i]); for (i = 0; i < 6; i++) scanf("%d", &b[i]); scanf("%s", x); if (x[0] == 'W') y = 1; else if (x[0] == 'T') y = 2; else if (x[0] == 'M') y = 3; else if (x[0] == 'O') y = 4; else y = 5; cnt = 0; for (i = 1; i < 6; i++) if (i != y && b[i] > 0) cnt++; if (cnt > 0) { printf("No\n"); continue; } cnt = 0; for (i = 1; i < 6; i++) cnt += a[i]; if (cnt > b[y]) printf("No\n"); else printf("Yes\n"); } return 0; }