/*
 * ICPC Greater NY Regional Contest, Nov 18, 2018
 * Potato Sack solution by John Buck, C-Scape Consulting Corp.
 *
 * This could be done A LOT more efficiently using subroutines, but
 * we try to keep the solution as simple as possible for the "A" problem.
 *
 * Remember, all we care about is whether or not there is a solution.  We do not care
 * if it's the best one.
 */
#include <stdio.h>
#include <stdlib.h>

#define	NUM_POTATOES	10
#define	MAX_POTATO_WT	3

int main()
{
	int p, k, c, c1, c2, c3, i, j, wt, m, n, done;
	int counts[MAX_POTATO_WT+1];

	p = 0;
	scanf("%d", &(p));
	for(i = 1; i <= p; i++){
		if(scanf("%d %d", &(k), &(c)) != 2){
			break;
		}
		/* We deliberately do not use element 0, since the index is a potato weight */
		for(j = 1; j <= MAX_POTATO_WT; j++){
			counts[j] = 0;
		}
		for(j = 0; j < NUM_POTATOES; j++){
			if(scanf("%d", &(wt)) != 1){
				break;
			}
			counts[wt]++;
		}
		if(j < NUM_POTATOES){
			break;
		}
		done = 0;
		for(m = 0; m <= counts[MAX_POTATO_WT]; m++){
			c1 = c - m*MAX_POTATO_WT;
			if(c1 < 0){
					break;
			}
			if(c1 == 0){
				done = 1;
				break;
			}
			for(j = 0; j <= counts[MAX_POTATO_WT-1]; j++){
				c2 = c1 - j*(MAX_POTATO_WT-1);
				if(c2 < 0){
					break;
				}
				if(c2 == 0){
					done = 1;
					break;
				}
				for(n = 0; n <= counts[MAX_POTATO_WT-2]; n++){
					c3 = c2 - n*(MAX_POTATO_WT-2);
					if(c3 < 0){
						break;
					}
					if(c3 == 0){
						done = 1;
						break;
					}
				}
				if(done == 1){
					break;
				}
			}
			if(done == 1){
				break;
			}
		}
		if(done == 1){
			printf("%d YES\n", k);
		} else {
			printf("%d NO\n", k);
		}
	}
	return(0);
}
