#include // int tmp, var = 0; を先に宣言する #define rd_int(var, tmp) \ for (;;) { \ tmp = getc_unlocked(stdin); \ if (tmp < '0' || tmp > '9') break; \ var = var * 10 + tmp - '0'; \ } int main() { int tmp, n = 0, a[6], b[6]; rd_int(n, tmp); for (int i = 0; i < n; ++i) { a[0] = a[1] = a[2] = a[3] = a[4] = a[5] = 0; rd_int(a[0], tmp); rd_int(a[1], tmp); rd_int(a[2], tmp); rd_int(a[3], tmp); rd_int(a[4], tmp); rd_int(a[5], tmp); b[0] = b[1] = b[2] = b[3] = b[4] = b[5] = 0; rd_int(b[0], tmp); rd_int(b[1], tmp); rd_int(b[2], tmp); rd_int(b[3], tmp); rd_int(b[4], tmp); rd_int(b[5], tmp); char c = getc_unlocked(stdin); getc_unlocked(stdin); getc_unlocked(stdin); if (c == 'T' || c == 'M' || c == 'O') getc_unlocked(stdin); int idx = (c == 'W') ? 1 : // (c == 'T') ? 2 : // (c == 'M') ? 3 : // (c == 'O') ? 4 : 5; int sum1 = a[1] + a[2] + a[3] + a[4] + a[5]; int sum2 = b[1] + b[2] + b[3] + b[4] + b[5]; if (a[idx] == 0 && b[idx] >= sum1 && b[idx] == sum2) { putc_unlocked('Y', stdout); putc_unlocked('e', stdout); putc_unlocked('s', stdout); } else { putc_unlocked('N', stdout); putc_unlocked('o', stdout); } putc_unlocked('\n', stdout); } return 0; }