In the mysterious country of Byteland, everything is quite different from what you'd 

normally expect. In most places, if you were approached by two mobsters in a dark alley, they would 

probably tell you to give them all the money that you have. If you refused, or didn't have any - 

they might even beat you up.

In Byteland the government decided that even the slightest chance of someone getting injured has to be ruled out. So, they introduced a strict policy. When a mobster approaches you in a dark 

alley, he asks you for a specific amount of money. You are obliged to show him all the money that 

you have, but you only need to pay up if he can find a subset of your banknotes whose total value 

matches his demand. Since banknotes in Byteland can have any positive integer value smaller than 

one thousand you are quite likely to get off without paying.

Both the citizens and the gangsters of Byteland have very positive feelings about the system. No one ever 

gets hurt, the gangsters don't lose their jobs, and there are quite a few rules that minimize that 
probability of getting mugged (the first one is: don't go into dark alleys - and this one is said to work in other places also).

------ Input ------ 

The first line contains integer t, the number of test cases (about 100). Then t test cases follow. Each test case starts with n, the 

number of banknotes in your wallet, and m, the amount of money the muggers asked of you. Then n 

numbers follow, representing values of your banknotes. Your wallet does not hold more than 20 banknotes, and the value of a single banknote is never more than 1000.

------ Output ------ 

For each test case output a single line with the word 'Yes' if there is a subset of your banknotes that sums  to m, and 'No' otherwise.

----- Sample Input 1 ------ 
5
3 3
1
1
1
5 11
1
2
4
8
16
5 23
1
2
4
8
16
5 13
1
5
5
10
10
20 132
17
6
4
998
254
137
259
153
154
3
28
19
123
542
857
23
687
35
99
999
----- Sample Output 1 ------ 
Yes
Yes
Yes
No
Yes
----- explanation 1 ------ 
For example, in the last case you have to pay up, since: 6+3+123=132.

Source: codechef | Difficulty: MEDIUM
Tags: Dynamic programming

Bit manipulation

Mathematics

Complete search


Solutions:
def findAll(arr, n, asum):
	dp = {0}
	arr = filter(lambda x: x <= asum, arr)
	for note in arr:
		new_sums = set(map(lambda x: x + note, dp))
		if asum in new_sums:
			return 'Yes'
		dp = dp.union(new_sums)
	else:
		return 'No'

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		arr = map(int, [input() for _ in range(n)])
		ans = findAll(arr, n, m)
		print(ans)
main()


def shouldntwe(vals, wanted):
	d = {}

	def shouldwe(indx, wanted):
		if (indx, wanted) in d:
			return d[indx, wanted]
		if indx == 0:
			if wanted - vals[indx] == 0:
				return 1
			else:
				return 0
		if wanted == 0:
			return 1
		nitch_there = shouldwe(indx - 1, wanted)
		ist_there = 0
		if wanted >= vals[indx]:
			ist_there = shouldwe(indx - 1, wanted - vals[indx])
		d[indx, wanted] = nitch_there or ist_there
		return d[indx, wanted]
	return shouldwe(len(vals) - 1, wanted)
t = int(input())
for abc in range(t):
	(n, m) = map(int, input().split())
	notes = [int(input()) for inp in range(n)]
	if shouldntwe(notes, m):
		print('Yes')
	else:
		print('No')


def sumUpTo(index, money, notesArr, dp):
	if money == 0:
		return True
	elif money < 0:
		return False
	elif index >= len(notesArr):
		return False
	elif dp[index][money] != None:
		return dp[index][money]
	else:
		take = sumUpTo(index + 1, money - notesArr[index], notesArr, dp)
		dontTake = sumUpTo(index + 1, money, notesArr, dp)
		dp[index][money] = take or dontTake
		return dp[index][money]
test_case = int(input())
results = []
for test in range(test_case):
	arr = input().split(' ')
	notes = int(arr[0])
	money = int(arr[1])
	notesArr = []
	for i in range(notes):
		notesArr.append(int(input()))
	dp = []
	for index in range(len(notesArr)):
		dp_row = []
		for m in range(money + 1):
			dp_row.append(None)
		dp.append(dp_row)
	results.append(sumUpTo(0, money, notesArr, dp))
for r in results:
	if r == True:
		print('Yes')
	else:
		print('No')


def fun(m, l):
	if m == 0:
		return True
	elif m < 0:
		return False
	if len(l) == 0:
		return False
	for i in range(len(l)):
		l1 = l.copy()
		m1 = m - l1[i]
		del l1[i]
		s = fun(m1, l1)
		if s:
			return s
	return False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		a = int(input())
		if a <= m:
			l.append(a)
	print('Yes' if fun(m, l) else 'No')


def ans(n, m, notes, memo={}):
	if m == 0:
		return True
	if m < 0:
		return False
	if n == 0:
		return False
	return ans(n - 1, m - notes[0], notes[1:]) or ans(n - 1, m, notes[1:])
	return False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	notes = []
	for i in range(n):
		notes.append(int(input()))
	if ans(n, m, notes):
		print('Yes')
	else:
		print('No')


def solve(n, m, notes):
	if m < 0:
		return False
	if m == 0:
		return True
	ncopy = notes[:]
	for note in notes:
		ncopy.remove(note)
		if solve(n - 1, m - note, ncopy):
			return True
		ncopy += [note]
for t in range(int(input())):
	(n, m) = map(int, input().split())
	notes = []
	for v in range(n):
		notes += [int(input())]
	if solve(n, m, notes):
		print('Yes')
	else:
		print('No')


for tc in range(1, int(input()) + 1):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(int(input()))
	dp = [[0] * (m + 1) for _ in range(n + 1)]
	for j in range(m + 1):
		dp[0][j] = 0
	for i in range(n + 1):
		dp[i][0] = 1
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			if arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] or dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	print('Yes' if dp[n][m] else 'No')


from functools import lru_cache

def soln(n, m, arr):
	dp = {}

	def recur(ind, amt):
		if ind >= n:
			if amt < 0:
				return False
			elif amt == 0:
				return True
		if (ind, amt) in dp:
			return dp[ind, amt]
		for i in range(ind, n):
			res = recur(ind + 1, amt - arr[ind]) | recur(ind + 1, amt)
			if res:
				dp[ind, amt] = True
				return True
		dp[ind, amt] = False
		return False
	return 'Yes' if recur(0, m) else 'No'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [int(input()) for i in range(n)]
	print(soln(n, m, arr))


tests = int(input())
for i in range(tests):
	(n, m) = map(int, input().split())
	notes_arr = []
	for j in range(n):
		notes_arr.append(int(input()))
	ans = 'No'
	for j in range(1, 2 ** n):
		temp = 0
		count = 0
		while j != 0:
			if j & 1:
				temp += notes_arr[count]
			count += 1
			j >>= 1
		if temp == m:
			ans = 'Yes'
			break
	print(ans)


def coin_change(coins, amount):
	memo = {}

	def helper(indx, amount):
		if (indx, amount) in memo:
			return memo[indx, amount]
		if indx == 0:
			if amount - coins[indx] == 0:
				return True
			else:
				return False
		if amount == 0:
			return True
		notpick = helper(indx - 1, amount)
		pick = False
		if amount >= coins[indx]:
			pick = helper(indx - 1, amount - coins[indx])
		memo[indx, amount] = pick or notpick
		return memo[indx, amount]
	return helper(len(coins) - 1, amount)
for _ in range(int(input())):
	(a, b) = map(int, input().split(' '))
	coins = []
	for _ in range(a):
		coins.append(int(input()))
	if coin_change(coins, b):
		print('Yes')
	else:
		print('No')


def issubset(L, p, k):
	if k == 0:
		return True
	if p == 0:
		return False
	return issubset(L, p - 1, k) or issubset(L, p - 1, k - L[p - 1])
T = int(input())
for tc in range(T):
	(n, k) = map(int, input().split())
	L = []
	for i in range(n):
		t = int(input())
		L.append(t)
	x = issubset(L, n, k)
	if x == True:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	(n, s) = [int(i) for i in input().split()]
	arr = [int(input()) for i in range(n)]
	dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
	for i in dp:
		i[0] = 1
	for i in range(1, n + 1):
		for j in range(1, s + 1):
			if j < arr[i - 1]:
				dp[i][j] = dp[i - 1][j]
			elif dp[i - 1][j]:
				dp[i][j] = 1
			else:
				dp[i][j] = dp[i - 1][j - arr[i - 1]]
	if dp[n][s]:
		print('Yes')
	else:
		print('No')


def solve():
	(n, amt) = map(int, input().split())
	dp = [[0] * (amt + 1) for i in range(n + 1)]
	lis = list()
	for i in range(n):
		lis.append(int(input()))
	for i in range(1, n + 1):
		for j in range(1, amt + 1):
			if lis[i - 1] <= j:
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - lis[i - 1]] + lis[i - 1])
			else:
				dp[i][j] = dp[i - 1][j]
	print(['Yes', 'No'][dp[n][amt] != amt])
for _ in range(int(input())):
	solve()


def Helper(A, num, target, hashTable):
	if target == 0:
		return True
	if num == 0:
		return False
	if target < 0:
		return False
	if (num, target) in hashTable:
		return hashTable[num, target]
	for i in range(len(A)):
		if num & 1 << i == 0:
			continue
		val = num & ~(1 << i)
		value = Helper(A, val, target - A[i], hashTable)
		if value:
			hashTable[num, target] = True
			return True
	hashTable[num, target] = False
	return False

def function(A, N, M):
	num = ~(-1 << N)
	ans = Helper(A, num, M, {})
	if ans:
		return 'Yes'
	return 'No'

def main():
	T = int(input())
	for _ in range(T):
		(N, M) = list(map(int, input().split(' ')))
		A = []
		for i in range(N):
			A.append(int(input()))
		val = function(A, N, M)
		print(val)
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	yes = False
	for _ in range(n):
		x = int(input())
		if x <= m:
			a.append(x)
	ans = 0
	for i in range(1, pow(2, len(a))):
		for j in range(len(a)):
			if i & 1 << j:
				ans += a[j]
				if ans == m:
					yes = True
					break
		ans = 0
	if yes:
		print('Yes')
	else:
		print('No')


def pay(i, s):
	if s >= m:
		return s == m
	if i == n:
		return False
	return pay(i + 1, s) or pay(i + 1, s + a[i])
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for j in range(n):
		a += [int(input())]
	if pay(0, 0):
		print('Yes')
	else:
		print('No')


from functools import lru_cache

@lru_cache(maxsize=None)
def paying_up(wanted_sum, bank_notes):
	if wanted_sum == 0:
		return True
	if wanted_sum < 0:
		return False
	if not bank_notes:
		return False
	bank_note = bank_notes[-1]
	bank_notes = bank_notes[:-1]
	return paying_up(wanted_sum, bank_notes) or paying_up(wanted_sum - bank_note, bank_notes)
for testcase in range(int(input())):
	(n, wanted_sum) = [int(x) for x in input().split()]
	bank_notes = tuple((int(input()) for _ in range(n)))
	print('Yes' if paying_up(wanted_sum, bank_notes) else 'No')


import itertools
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ans = []
	comb = []
	flag = 0
	for j in range(n):
		k = int(input())
		if k <= m:
			ans.append(k)
	for g in range(len(ans) + 1):
		comb_obj = itertools.combinations(ans, g)
		comb += list(comb_obj)
	for g in comb:
		if sum(g) == m:
			flag = 1
	if flag == 1:
		print('Yes')
	else:
		print('No')


test_cases = int(input())
bank_notes = []

def solve():
	(bank_notes_num, m) = input().split()
	m = int(m)
	bank_notes_num = int(bank_notes_num)
	for bn in range(0, bank_notes_num):
		bn_val = int(input())
		bank_notes.append(bn_val)
	bank_notes.sort()
	subsets = [[]]
	for bn1 in bank_notes:
		subsets += [sub + [bn1] for sub in subsets]
	for s in subsets:
		if sum(s) == m:
			print('Yes')
			return
	print('No')
for t in range(0, test_cases):
	solve()
	bank_notes = []


t = int(input())
while t > 0:
	t -= 1
	(n, m) = [int(x) for x in input().split()]
	a = []
	for i in range(n):
		x = int(input())
		a.append(x)
	can = False
	for i in range(1 << n):
		tot = 0
		for j in range(n):
			if i & 1 << j:
				tot += a[j]
		if tot == m:
			can = True
			break
	print('Yes' if can else 'No')


def eAll(arr, i, cs, trg):
	if i >= len(arr):
		return False
	if trg == cs + arr[i]:
		return True
	if arr[i] + cs > trg:
		return False
	return eAll(arr, i + 1, cs + arr[i], trg) or eAll(arr, i + 1, cs, trg)
tn = int(input())
for _ in range(tn):
	(n, m) = map(int, input().split())
	arr = [int(input()) for _ in range(n)]
	arr.sort()
	if eAll(arr, 0, 0, m):
		print('Yes')
	else:
		print('No')


def isSubsetSum(arr, n, target):
	if target == 0:
		return True
	if n == 0:
		return False
	if arr[n - 1] > target:
		return isSubsetSum(arr, n - 1, target)
	return isSubsetSum(arr, n - 1, target) or isSubsetSum(arr, n - 1, target - arr[n - 1])
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	notes = []
	for _ in range(n):
		notes.append(int(input()))
	if isSubsetSum(notes, n, m):
		print('Yes')
	else:
		print('No')


test = int(input())
for i in range(test):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(int(input()))

	def subs(arr):
		subs = [[]]
		dp = []
		for elem in arr:
			for i in range(len(subs)):
				a = subs[i] + [elem]
				subs.append(a)
				dp.append(sum(a))
		return dp
	if m in subs(arr):
		print('Yes')
	else:
		print('No')


def change(i, total, memo):
	if (i, total) in memo:
		return memo[i, total]
	if total == m:
		memo[i, total] = True
		return memo[i, total]
	if i >= n or total > m:
		memo[i, total] = False
		return memo[i, total]
	memo[i, total] = change(i + 1, total + notes[i], memo) or change(i + 1, total, memo)
	return memo[i, total]
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	notes = [-1 for _ in range(n)]
	for i in range(n):
		notes[i] = int(input())
	print('Yes' if change(0, 0, {}) else 'No')


def subs(li, arr, subset, index):
	li.append(subset.copy())
	for i in range(index, len(arr)):
		subset.append(arr[i])
		subs(li, arr, subset, i + 1)
		subset.pop()
	return
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = []
	li = []
	for i in range(n):
		a.append(int(input()))
	subs(li, a, [], 0)
	out = []
	for i in li:
		if len(i) == 0:
			out.append(0)
		elif len(i) == 1:
			out.append(i[0])
		else:
			out.append(sum(i))
	try:
		out.index(m)
		print('Yes')
	except:
		print('No')


def knapsack(arr, total, cnt):
	k = [[0 for i in range(total + 1)] for j in range(cnt + 1)]
	for i in range(1, cnt + 1):
		for j in range(1, total + 1):
			if j >= arr[i - 1]:
				k[i][j] = max(k[i - 1][j], k[i - 1][j - arr[i - 1]] + arr[i - 1])
			else:
				k[i][j] = k[i - 1][j]
	return k[cnt][total]
T = int(input())
for t in range(T):
	(n, m) = [int(x) for x in input().split(' ')]
	arr = []
	for i in range(n):
		arr.append(int(input()))
	if m > 20000:
		print('No')
	elif m == knapsack(arr, m, n):
		print('Yes')
	else:
		print('No')


def checkSubsetSum(a, m, n, memo):
	if m == 0:
		return True
	if m < 0:
		return False
	if m in memo:
		return memo[m]
	for i in range(n):
		rem = m - a[i]
		if checkSubsetSum(a[:i] + a[i + 1:], rem, n - 1, memo):
			memo[m] = True
			return True
	memo[m] = False
	return False
t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	a = []
	for i in range(n):
		a.append(int(input()))
	if checkSubsetSum(a, m, n, {}):
		print('Yes')
	else:
		print('No')


import itertools
n1 = int(input())
for i in range(n1):
	(n, m) = map(int, input().split())
	list = []
	for j in range(n):
		list.append(int(input()))
	p = 'No'
	for k in range(1, n + 1):
		for l in itertools.combinations(list, k):
			if sum(l) == m:
				p = 'Yes'
				break
	print(p)


import itertools
num = int(input())
for i in range(num):
	(n, m) = map(int, input().split())
	lst = []
	for j in range(n):
		lst.append(int(input()))
	pay = 'No'
	for k in range(1, n + 1):
		for l in itertools.combinations(lst, k):
			if sum(l) == m:
				pay = 'Yes'
				break
	print(pay)


def solve(n, arr, ind, amt, dp):
	if amt == 0:
		return True
	if amt < 0:
		return False
	if (ind, amt) in dp:
		return dp[ind, amt]
	if ind > n - 1:
		return False
	dp[ind, amt] = solve(n, arr, ind + 1, amt - arr[ind], dp) or solve(n, arr, ind + 1, amt, dp)
	return dp[ind, amt]
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	arr = [0] * n
	for i in range(n):
		arr[i] = int(input())
	if solve(n, arr, 0, m, {}):
		print('Yes')
	else:
		print('No')


t = int(input())

def bt(i, target, l):
	if target == 0:
		return True
	if i == len(l) - 1:
		return target == l[-1]
	not_take = bt(i + 1, target, l)
	take = False
	if l[i] <= target:
		take = bt(i + 1, target - l[i], l)
	return take or not_take
for _ in range(t):
	(n, m) = map(int, input().split())
	dp = [-1] * 20000
	l = []
	key = 0
	for _ in range(n):
		l.append(int(input()))
	if bt(0, m, l):
		print('Yes')
	else:
		print('No')


t = int(input())
from itertools import chain, combinations

def powerset(list_name):
	s = list(list_name)
	l = []
	for i in range(1, len(list_name) + 1):
		for x in combinations(s, i):
			l.append(x)
	return l
for _ in range(t):
	(n, m) = map(int, input().split())
	dp = [-1] * 20000
	l = []
	key = 0
	for _ in range(n):
		l.append(int(input()))
	for x in powerset(l):
		if sum(x) == m:
			key = -1
			break
	if key == 0:
		print('No')
	else:
		print('Yes')


import sys
sys.setrecursionlimit(2 ** 30)

def ans(start, arr, t):
	if start == len(arr) and t == 0:
		return True
	if start == len(arr) and t != 0:
		return False
	if start > len(arr):
		return False
	if t == 0:
		return True
	elif arr[start] > t:
		return ans(start + 1, arr, t)
	else:
		return ans(start + 1, arr, t - arr[start]) or ans(start + 1, arr, t)
test_cases = int(input())
while test_cases != 0:
	d = list(map(int, input().split()))
	arr = []
	for y in range(0, d[0]):
		temp = int(input())
		arr.append(temp)
	x = ans(0, arr, d[1])
	if x is True:
		print('Yes')
	else:
		print('No')
	test_cases -= 1


from itertools import chain, combinations

def power_set(list_name):
	given_set = list(list_name)
	return chain.from_iterable((combinations(given_set, r) for r in range(len(given_set) + 1)))
inp_t = int(input())
while inp_t:
	(inp_n, inp_m) = input().split()
	(inp_n, inp_m) = (int(inp_n), int(inp_m))
	pocket_currency = []
	while inp_n:
		pocket_currency.append(int(input()))
		inp_n = inp_n - 1
	pocket_currency = sorted(pocket_currency)
	super_set_pocket_currency = power_set(pocket_currency)
	flag = False
	for each_set in super_set_pocket_currency:
		if sum(each_set) == inp_m:
			print('Yes')
			flag = True
			break
	if flag is False:
		print('No')
	inp_t = inp_t - 1


def solvemug(m, L):
	if m == 0:
		return True
	elif len(L) == 0:
		return False
	elif m >= L[0]:
		(a, b) = (solvemug(m - L[0], L[1:]), solvemug(m, L[1:]))
		return a or b
	else:
		a = solvemug(m, L[1:])
		return a
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	L = []
	for i in range(n):
		L.append(int(input()))
	if solvemug(m, L):
		print('Yes')
	else:
		print('No')


def fx(ind, target, arr):
	if target == 0:
		return True
	if ind == 0:
		k = arr[0] == target
		return k
	not_take = fx(ind - 1, target, arr)
	take = False
	if target >= arr[ind]:
		take = fx(ind - 1, target - arr[ind], arr)
	return take or not_take
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	qw = []
	for k in range(n):
		t = int(input())
		qw.append(t)
	if fx(n - 1, m, qw):
		print('Yes')
	else:
		print('No')


try:
	from debug import debug, timer
except ImportError:
	pass
from sys import stdin
input = stdin.readline

def rii():
	return range(int(input().strip()))

def ii():
	return int(input().strip())

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())

def getvals():
	while True:
		yield from input().split()

def tri(n):
	return n * (n + 1) // 2

def smallest_first(m, n):
	return (min(m, n), max(m, n))
from functools import lru_cache
(success, failure) = ('Yes', 'No')

@lru_cache(maxsize=None)
def recursive_solve(m, wallet):
	if m == 0:
		return True
	if len(wallet) == 1:
		return bool(m == wallet[0])
	new_wallet = tuple(list(wallet)[1:])
	if wallet[0] <= m:
		return recursive_solve(m, new_wallet) | recursive_solve(m - wallet[0], new_wallet)
	else:
		return recursive_solve(m, new_wallet)

def solve(*args):
	(n, m, wallet) = args
	return success if recursive_solve(m, tuple(sorted(wallet, reverse=True))) else failure

def do_codechef():
	for t in rii():
		(n, m) = mii()
		wallet = [ii() for _ in range(n)]
		print(solve(n, m, wallet))
do_codechef()
exit()


def subsum(arr, i, n, su, s):
	if i == n:
		if su == s:
			return True
		return False
	if su + arr[i] <= s:
		return subsum(arr, i + 1, n, su + arr[i], s) or subsum(arr, i + 1, n, su, s)
	else:
		return subsum(arr, i + 1, n, su, s)
for _ in range(int(input())):
	(si, s) = [int(a) for a in input().split()]
	arr = []
	for l in range(si):
		arr.append(int(input()))
	if subsum(arr, 0, si, 0, s):
		print('Yes')
	else:
		print('No')


from itertools import chain, combinations

def powerset(list_name):
	s = list(list_name)
	return chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li = []
	for i in range(n):
		li.append(int(input()))
	li.sort()
	fnd = False
	for a in powerset(li):
		if sum(a) == m:
			fnd = True
	if fnd:
		print('Yes')
	else:
		print('No')


def call(arr, banknotes, amount):
	dp = [[0] * (amount + 1) for i in range(banknotes + 1)]
	for i in range(banknotes + 1):
		dp[i][0] = 1
	for i in range(1, banknotes + 1):
		for j in range(1, amount + 1):
			if j >= arr[i - 1]:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]
			else:
				dp[i][j] = dp[i - 1][j]
	return 'Yes' if dp[banknotes][amount] else 'No'
t = int(input())
while t > 0:
	arr = list(map(int, input().split()))
	(banknotes, amount) = (arr[0], arr[1])
	arr = []
	for i in range(banknotes):
		arr.append(int(input()))
	print(call(arr, banknotes, amount))
	t -= 1


import itertools
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	h = True
	for _ in range(n):
		l.append(int(input()))
	for i in range(1, n + 1):
		if h:
			a = list(itertools.combinations(l, i))
			for j in a:
				if sum(j) == k:
					h = False
					print('Yes')
					break
	if h:
		print('No')


from itertools import combinations
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = []
	count = 0
	for i in range(n):
		a.append(int(input()))
	for i in range(1, n + 1):
		if count == 1:
			break
		for j in combinations(a, i):
			if sum(j) == m:
				count = 1
				print('Yes')
				break
	if count != 1:
		print('No')


from itertools import combinations
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	c = 0
	for i in range(n):
		a += [int(input())]
	for i in range(1, n + 1):
		if c == 1:
			break
		for j in combinations(a, i):
			if sum(j) == m:
				c = 1
				print('Yes')
				break
	if c != 1:
		print('No')


def sub(l, i, curr_sum, k):
	if i == len(l):
		if curr_sum == k:
			return True
		else:
			return False
	if curr_sum == k:
		return True
	inc = sub(l, i + 1, curr_sum + l[i], k)
	exc = sub(l, i + 1, curr_sum, k)
	return inc or exc
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(int(input()))
	l.sort()
	ans = sub(l, 0, 0, m)
	if ans:
		print('Yes')
	else:
		print('No')


import itertools
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	bn = []
	pay = False
	for i in range(n):
		bn.append(int(input()))
	for i in range(1, n + 1):
		if not pay:
			for c in itertools.combinations(bn, i):
				if sum(c) == m:
					pay = True
					break
	if pay:
		print('Yes')
	else:
		print('No')


from itertools import combinations
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	l = []
	for j in range(n):
		l.append(int(input()))
	a = []
	for i in range(n):
		b = list(combinations(l, i + 1))
		a += b
	flag = 0
	for i in a:
		if sum(i) == m:
			print('Yes')
			flag = 1
			break
	if flag == 0:
		print('No')


def resuo(nums, act):
	n = len(nums)
	sol = []
	count = 1 << n
	for mask in range(count):
		ans = []
		for i in range(n):
			if mask & 1 << i != 0:
				ans.append(nums[i])
		sol.append(sum(ans))
	for i in sol:
		if i == act:
			return 'Yes'
	return 'No'

def into():
	T = int(input())
	for i in range(T):
		arr = list(map(int, input().rstrip().split()))
		act = arr[1]
		nums = []
		for i in range(arr[0]):
			k = int(input())
			nums.append(k)
		res = resuo(nums, act)
		print(res)
into()


for t in range(0, int(input())):
	(n, k) = map(int, input().split())
	arr = []
	for i in range(0, n):
		j = int(input())
		if j <= k:
			arr.append(j)
	total = 0
	c = 0
	n = len(arr)
	for i in range(0, 2 ** n):
		total = 0
		for j in range(0, n):
			if 1 << j & i:
				total += arr[j]
		if total == k:
			print('Yes')
			c = 1
			break
	if c == 0:
		print('No')


import itertools
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for _ in range(n):
		b = int(input())
		a.append(b)
	pay = 'No'
	for k in range(1, n + 1):
		for l in itertools.combinations(a, k):
			if sum(l) == m:
				pay = 'Yes'
				break
	print(pay)


def isSubsetSum(sett, no, summ):
	if summ == 0:
		return True
	if no == 0:
		return False
	if sett[no - 1] > summ:
		return isSubsetSum(sett, no - 1, summ)
	return isSubsetSum(sett, no - 1, summ) or isSubsetSum(sett, no - 1, summ - sett[no - 1])
T = int(input().strip())
for t in range(0, T):
	(n, m) = input().strip().split()
	n = int(n)
	m = int(m)
	l = []
	for i in range(0, n):
		p = int(input().strip())
		l.append(p)
	a = isSubsetSum(l, len(l), m)
	if a == True:
		print('Yes')
	else:
		print('No')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
t = int(input())
for t1 in range(t):
	(n, m) = map(int, input().split())
	ls = []
	for n1 in range(n):
		a = int(input())
		ls.append(a)
	if isSubsetSum(ls, n, m) == True:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	c = 0
	l = []
	for i in range(n):
		k = int(input())
		if k <= m:
			l.append(k)
			c += 1
	l.sort()
	s = 0
	c1 = 0
	f = 0
	for i in range(1, 2 ** c):
		while i != 0:
			if i % 2 != 0:
				s += l[c1]
			if s == m:
				f = 1
				break
			elif s > m:
				break
			c1 += 1
			i = i >> 1
		c1 = 0
		s = 0
		if f == 1:
			break
	if f == 1:
		print('Yes')
	else:
		print('No')


import itertools
t = int(input())
for i in range(t):
	(notes, demand) = map(int, input().split())
	bankNotes = []
	for i in range(notes):
		bankNotes.append(int(input()))
	pay = 'No'
	for k in range(1, notes + 1):
		for l in itertools.combinations(bankNotes, k):
			if sum(l) == demand:
				pay = 'Yes'
				break
	print(pay)