Nezzar's favorite digit among $1,\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.

Given $q$ integers $a_1,a_2,\ldots,a_q$, for each $1 \le i \le q$ Nezzar would like to know if $a_i$ can be equal to a sum of several (one or more) lucky numbers.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 9$) — the number of test cases.

The first line of each test case contains two integers $q$ and $d$ ($1 \le q \le 10^4$, $1 \le d \le 9$).

The second line of each test case contains $q$ integers $a_1,a_2,\ldots,a_q$ ($1 \le a_i \le 10^9$).


-----Output-----

For each integer in each test case, print "YES" in a single line if $a_i$ can be equal to a sum of lucky numbers. Otherwise, print "NO".

You can print letters in any case (upper or lower).


-----Examples-----

Input
2
3 7
24 25 27
10 7
51 52 53 54 55 56 57 58 59 60
Output
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO


-----Note-----

In the first test case, $24 = 17 + 7$, $27$ itself is a lucky number, $25$ cannot be equal to a sum of lucky numbers.

Difficulty: EASY

Solutions:
def isLucky(number, lucky, memo):
	if number in memo:
		return memo[number]
	if number == lucky:
		memo[number] = True
		return True
	elif number < lucky:
		memo[number] = False
		return False
	else:
		if str(lucky) in str(number):
			memo[number] = True
			return True
		memo[number] = isLucky(number - lucky, lucky, memo)
		return isLucky(number - lucky, lucky, memo)
t = int(input())
for _ in range(t):
	(q, d) = [int(x) for x in input().split()]
	numbers = [int(x) for x in input().split()]
	memo = {}
	for num in numbers:
		if num >= d * 10:
			print('YES')
			continue
		elif isLucky(num, d, memo):
			print('YES')
		else:
			print('NO')


for testcase in range(int(input())):
	arr = [int(x) for x in input().split()]
	(n, d) = (arr[0], arr[1])
	s = set()
	arr = [int(x) for x in input().split()]
	for ele in arr:
		if ele % d == 0:
			print('YES')
			s.add(ele)
		elif str(d) in str(ele):
			print('YES')
			s.add(ele)
		else:
			ele1 = ele
			while ele > 0:
				ele -= d
				if str(d) in str(ele):
					print('YES')
					s.add(ele1)
					break
			else:
				print('NO')


t = int(input())
res = [[] for i in range(10)]
for i in range(1, 10):
	for j in range(1, 10):
		k = i * j
		s = str(k)
		res[i].append([s[-1], k])
for i in range(t):
	(n, d) = map(int, input().split())
	b = list(map(int, input().split()))
	for j in range(n):
		curr = b[j]
		s = str(curr)[-1]
		f = 0
		for k in res[d]:
			if k[0] == s[0] and curr >= k[1]:
				f = 1
				break
		if f or curr >= 10 * d:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		f = 0
		while i > 0:
			if str(k) in str(i):
				f = 1
				break
			i -= k
		if f == 1:
			print('YES')
		else:
			print('NO')


import sys
sys.setrecursionlimit(1000000)
from collections import defaultdict, deque, Counter
from itertools import permutations
from math import sqrt, gcd, pi, factorial
from functools import reduce
from sys import stdin
from bisect import bisect_right, bisect_left
from copy import copy
from heapq import heapify, heappop, heappush
import time
from random import randrange
MAX = 100

def solve(n, d, a):
	dp = [False for _ in range(MAX + 1)]
	dp[0] = True
	for i in range(1, MAX + 1):
		for j in range(1, i + 1):
			if dp[i - j] and str(d) in str(j):
				dp[i] = True
				break
	ret = [aa > 100 or dp[aa] for aa in a]
	return ret
t = int(input())
anss = [[] for _ in range(t)]
for i in range(t):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	anss[i] = solve(n, d, a)
for ans in anss:
	for a in ans:
		if a:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(q, d) = map(int, input().split())
	s = input()
	a = list(s.split())
	for k in a:
		if k.find(str(d)) != -1:
			print('YES')
		else:
			j = int(k) - d
			if j >= 10 * d:
				print('YES')
			elif j >= 0 and (j % 10 == d or (j % 10 == 2 * d % 10 and j >= 2 * d) or (j % 10 == 3 * d % 10 and j >= 3 * d) or (j % 10 == 4 * d % 10 and j >= 4 * d) or (j % 10 == 5 * d % 10 and j >= 5 * d) or (j % 10 == 6 * d % 10 and j >= 6 * d) or (j % 10 == 7 * d % 10 and j >= 7 * d) or (j % 10 == 8 * d % 10 and j >= 8 * d) or (j % 10 == 9 * d % 10 and j >= 9 * d)):
				print('YES')
			else:
				print('NO')


from collections import *
from math import *
mn = []
for i in range(10):
	if i == 0:
		mn.append([])
		continue
	ck = [0] * 105
	d = i
	arr = [d]
	t = 10
	for i in range(10):
		arr.append(t + d)
		t += 10
	ck = [0] * 105
	ck[0] = 1
	for i in range(102):
		for j in arr:
			if j > i:
				break
			if ck[i - j] == 1:
				ck[i] = 1
	mn.append(ck)
TT = int(input())
for y in range(TT):
	(n, d) = map(int, input().split())
	lst = list(map(int, input().split()))
	arr = [d]
	t = 10
	for i in range(10):
		arr.append(t + d)
		t += 10
	for temp in lst:
		if temp < d:
			print('NO')
		elif d * 10 <= temp:
			print('YES')
		elif mn[d][temp] == 1:
			print('YES')
		else:
			print('NO')


def main():
	for _ in range(int(input())):
		input_list = list(map(int, input().split(' ')))
		(q, d) = (input_list[0], input_list[1])
		a = list(map(int, input().split(' ')))
		for x in a:
			if x >= 10 * d:
				print('YES')
				continue
			else:
				x = x - d
				while x % 10 != 0 and x >= 0:
					x = x - d
				if x >= 0:
					print('YES')
				else:
					print('NO')
main()


def main():
	t = int(input())
	while t > 0:
		line = input().split(' ')
		k = int(line[0])
		d = int(line[1])
		numbers = list(map(int, input().split(' ')))
		for x in numbers:
			if x % d == 0:
				print('YES')
			elif x >= 10 * d:
				print('YES')
			else:
				es = False
				for y in range(1, 9):
					if (x - y * d) % 10 == 0 and y * d <= x:
						es = True
						break
				if es:
					print('YES')
				else:
					print('NO')
		t -= 1
main()


import math
import sys
input = sys.stdin.readline
from collections import Counter, defaultdict, deque

def f(n, a, x):
	res = []
	l = []
	for rem in range(1, n):
		num = n
		flag = False
		while num < 10 ** 9 + 1:
			cn = str(num + rem)
			for dig in cn:
				if dig == str(n):
					l.append(num + rem)
					flag = True
			if flag:
				break
			num += n
		else:
			l.append(10 ** 9 + 1)
	for num in a:
		snum = str(num)
		for dig in snum:
			if dig == str(n):
				res.append('YES')
				break
		else:
			r = num % n
			if r == 0 or num > l[r - 1]:
				res.append('YES')
			else:
				res.append('NO')
	return res
t = int(input())
result = []
for i in range(t):
	(x, n) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	result.append(f(n, a, x))
for i in range(t):
	for l in range(len(result[i])):
		print(result[i][l])


for _ in range(int(input())):
	(n, d) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	for i in l:
		vb = i
		vb %= d
		cant = False
		while True:
			if vb == 0:
				break
			vb += d
			if vb > i:
				cant = True
				break
			if str(d) in str(vb):
				break
		if not cant:
			print('YES')
		else:
			print('NO')


def isDigitPresent(x, d):
	while x > 0:
		if x % 10 == d:
			break
		x = x / 10
	return x > 0

def Array(n):
	arr = [False] * (10 * n)
	for i in range(1, 10 * n):
		arr[i] = isDigitPresent(i, n)
	arr[0] = True
	for i in range(1, 10 * n):
		if not arr[i]:
			for j in range(i - 1, 0, -1):
				if arr[j]:
					if arr[i % j]:
						arr[i] = True
	arr[0] = False
	return arr
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	sol_Arr = Array(d)
	for i in arr:
		if i >= 10 * d:
			print('YES')
		elif sol_Arr[i]:
			print('YES')
		else:
			print('NO')


T = int(input())
r = 1

def judge(num, d):
	if num >= 10 * d:
		return True
	while num > 0:
		if num % 10 == d:
			return True
		num -= d
	return False
while r <= T:
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = []
	for ele in arr:
		flag = judge(ele, d)
		if flag:
			print('YES')
		else:
			print('NO')
	r += 1


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
tc = 1
(tc,) = inp()
for _ in range(tc):
	(n, d) = inp()
	a = inp()
	dp = [False for i in range(10 * d)]
	dp[0] = dp[d] = True
	for i in range(10 * d):
		if str(d) in str(i):
			dp[i] = True
		for j in range(i):
			if dp[j] and dp[i - j]:
				dp[i] = True
	for i in a:
		if 10 * d <= i or dp[i]:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = 10 * d
	dp = [0 for _ in range(mx)]
	i = 0
	while i * 10 + d < mx:
		dp[i * 10 + d] = 1
		i += 1
	for k in range(0, d):
		for w in range(mx - (k * 10 + d)):
			dp[k * 10 + d + w] |= dp[w]
	for n in a:
		if n >= 10 * d:
			print('YES')
		elif dp[n]:
			print('YES')
		else:
			print('NO')


def has(x, d):
	return str(x).count(str(d)) > 0
t = int(input())
for tc in range(t):
	(q, d) = map(int, input().split())
	a = map(int, input().split())
	dp = [0] * 1005
	dp[0] = 1
	for i in range(1, 1002):
		if has(i, d):
			for j in range(0, 1003 - i):
				if dp[j] > 0:
					dp[j + i] = 1
	for x in a:
		if x > 1000 or dp[x]:
			print('YES')
		else:
			print('NO')


test = int(input())
for _ in range(test):
	(n, d) = map(int, input().split())
	numbers = list(map(int, input().split()))
	for i in range(0, len(numbers)):
		if numbers[i] < d:
			print('NO')
		else:
			c = str(numbers[i])
			if str(d) in c:
				print('YES')
			else:
				flag = 0
				while numbers[i] - d > 0:
					numbers[i] = numbers[i] - d
					c = str(numbers[i])
					if str(d) in c:
						print('YES')
						flag = 1
						break
				if flag == 0:
					print('NO')


def ass(a, b):
	print(f'Assertion error: {a} != {b}' if a != b else 'OK')

def number():
	return int(input())

def numbers():
	return [int(item) for item in input().split()]

def word():
	return input()

def words():
	return [item for item in input().split()]

def dump(lst):
	for (i, item) in enumerate(lst):
		print(i, item)

def binsearch(arr, a, b):
	m = (a + b) // 2
	if a >= b:
		return a - 1 if arr[a] == 0 else a
	return binsearch(arr, a, m - 1) if arr[m] == 0 else binsearch(arr, m + 1, b)

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def make(n):
	res = []
	for i in range(1, 11):
		for j in range(n * i, n * 10 + 1, 10):
			res.append(j)
	res = list(set(res))
	res.sort()
	return res
table = [0]
for i in range(1, 10):
	table.append(make(i))

def f(d, item):
	t = table[d]
	return item >= t[-1] or item in t
for i in range(number()):
	(q, d) = numbers()
	for item in numbers():
		print('YES' if f(d, item) else 'NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(q, d) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	for num in a:
		if num >= d * 10:
			print('YES')
		else:
			luckyNumList = [False for _ in range(d * 10 + 1)]
			luckyNumList[d] = True
			for idx in range(d + 1, d * 10 + 1):
				if luckyNumList[idx - d] == True:
					luckyNumList[idx] = True
				elif idx > 10 and luckyNumList[idx - 10] == True:
					luckyNumList[idx] = True
			print('YES' if luckyNumList[num] else 'NO')


t = int(input())
while t:
	t -= 1
	(q, d) = input().split()
	(q, d) = (int(q), int(d))
	arr = [int(i) for i in input().split()]
	num = 1
	for val in arr:
		if val >= d * 10:
			print('YES')
		else:
			b = False
			while val > 0:
				if val % d == 0:
					b = True
					break
				val = val - 10
			if b:
				print('YES')
			else:
				print('NO')


t = int(input())
for t1 in range(0, t):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	d1 = {}
	for i in range(1, 11):
		z = i * d % 10
		if z not in d1:
			d1[z] = i * d
	ans = []
	for i in l:
		if i > d * 10:
			ans.append('YES')
		else:
			z = i % 10
			if z in d1:
				k = d1[z]
				if i < k:
					ans.append('NO')
				else:
					ans.append('YES')
			else:
				ans.append('NO')
	for i in ans:
		print(i)


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	for n in arr:
		if n >= 10 * d:
			print('YES')
		else:
			flag = False
			while n > 0:
				if n % d == 0:
					flag = True
					break
				else:
					n = n - 10
			if flag:
				print('YES')
			else:
				print('NO')


import sys
input = sys.stdin.readline

def solution(q, d, arr, l_d):
	luckies = list(range(d, 100, 10)) + list(range(d * 10, d * 10 + 10, 1))
	up_ = 100
	possibles = [False for _ in range(up_)]
	possibles[0] = True
	for luck_num in luckies:
		for i in range(up_ - luck_num):
			if possibles[i] is True:
				possibles[i + luck_num] = True
	for num in arr:
		if num >= up_ or possibles[num] is True:
			print('YES')
		else:
			print('NO')
T = int(input())
for t in range(T):
	[q, d] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	l_d = [None for _ in range(10)]
	for i in range(1, 11):
		cur = i * d
		rest = cur % 10
		if l_d[rest] is None:
			l_d[rest] = cur
	solution(q, d, arr, l_d)


for ashdjiasjd in range(int(input())):
	(_, d) = map(int, input().split())
	a = list(map(int, input().split()))
	dp = [0] * 100
	for i in range(d, 100):
		if i % 10 == d or i // 10 == d:
			dp[i] = 1
		if dp[i] == 1:
			for j in range(1, 100 // d):
				if i + j * d >= 99:
					break
				dp[i + j * d] = 1
	for x in a:
		if x < d * 10:
			print('YNEOS'[1 - dp[x]::2])
		else:
			print('YES')


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import Counter as C
for _ in range(it()):
	(n, d) = mp()
	l = mp()
	for j in l:
		while str(d) not in str(j):
			j -= d
		if j > 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	for i in range(n):
		x = l[i]
		f = False
		while x >= d:
			if str(d) in str(x):
				f = True
				break
			else:
				x -= d
		if f:
			print('YES')
		else:
			print('NO')


def to_digits(n):
	digits = []
	while n > 0:
		digits.append(n % 10)
		n = n // 10
	digits = digits[::-1]
	return digits

def get_luckies(n, d):
	agg = n * [False]
	for x in range(n):
		if d in to_digits(x):
			agg[x] = True
		else:
			for j in range(x):
				if agg[j] and agg[x - j]:
					agg[x] = True
	return agg

def main():
	maxn = 100
	t = int(input())
	for _ in range(t):
		(q, d) = map(int, input().split())
		xs = list(map(int, input().split()))
		luckies = get_luckies(maxn, d)
		for x in xs:
			print('NO' if x < maxn and (not luckies[x]) else 'YES')
	return None
main()


def main():
	t = int(input())
	ret = []
	for _ in range(t):
		(q, d) = map(int, input().split())
		b = d * 10
		for a in map(int, input().split()):
			if a >= b:
				print('YES')
			else:
				while a > 0:
					if a % d == 0:
						print('YES')
						break
					else:
						a -= 10
				else:
					print('NO')
main()


def f(n, t, d):
	if d in str(n):
		f(n + 1)
t = int(input())
while t:
	t -= 1
	(n, d) = map(int, input().split())
	A = list(map(int, input().split()))
	res = [0 for i in range(100)]
	res[0] = 1
	for tt in range(10):
		for i in range(100):
			if res[i]:
				for j in range(9):
					a = j + d * 10
					b = j * 10 + d
					for k in range(i, 100, a):
						res[k] = 1
					for k in range(i, 100, b):
						res[k] = 1
	for i in A:
		if i >= 100 or i % d == 0:
			print('YES')
		elif res[i]:
			print('YES')
		else:
			print('NO')


test_cases = int(input())
res = []
for test in range(test_cases):
	st = input()
	ls = st.split()
	q = int(ls[0])
	d = int(ls[1])
	st = input()
	ls = st.split()
	for val in ls:
		value = int(val)
		if value >= d * 10:
			res.append('YES')
		elif value % d == 0:
			res.append('YES')
		else:
			while value > 9:
				value -= 10
				if value % d == 0:
					break
			if value % d == 0 and value != 0:
				res.append('YES')
			else:
				res.append('NO')
for value in res:
	print(value)


import sys
from functools import lru_cache
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def good(n, d):
	return str(d) in str(n)
goods = {d: [] for d in range(1, 10)}
for d in range(1, 10):
	for x in range(1, 10 * d):
		if good(x, d):
			goods[d].append(x)
bads = {d: [] for d in range(1, 10)}

@lru_cache(maxsize=None)
def isg(n, d):
	if good(n, d):
		return True
	else:
		return any((isg(n - x, d) for x in goods[d] if x < n))
for d in range(1, 10):
	for x in range(1, 10 * d):
		if not isg(x, d):
			bads[d].append(x)

def solve(q, d, ass):
	for a in ass:
		if a >= 10 * d:
			print('YES')
		else:
			print('NO' if a in bads[d] else 'YES')
for _ in range(inp()):
	(q, d) = invr()
	ass = inlt()
	solve(q, d, ass)


cases = int(input())
for i in range(cases):
	(q, d) = list(map(int, input().split()))
	multiply_table = [max_dev for max_dev in range(d * 10, d * 10 + 10)]
	for i in range(1, 10):
		num_check = d * i
		box_in = num_check % 10
		if multiply_table[box_in] > num_check:
			multiply_table[box_in] = num_check
	list_num = list(map(int, input().split()))
	for each_num in list_num:
		unit = each_num % 10
		if multiply_table[unit] > each_num:
			print('NO')
		else:
			print('YES')


def nr():
	return int(input())

def nrs():
	return [int(item) for item in input().split()]
cache = {}

def lucky(d, item):
	if item in cache:
		return cache[item]
	if item < d:
		return False
	elif item >= d * 10:
		return True
	elif item % d == 0:
		return True
	elif item % 10 == d:
		return True
	res = lucky(d, item - d)
	cache[item] = res
	return res

def f(d, arr):
	cache.clear()
	for item in arr:
		print('YES' if lucky(d, item) else 'NO')
for _ in range(nr()):
	(q, d) = nrs()
	f(d, nrs())


t = int(input())
for _ in range(t):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		if i >= d * 10:
			ans = 'YES'
		else:
			ans = 'NO'
			while i >= d:
				if i % d == 0:
					ans = 'YES'
					break
				i -= 10
		print(ans)


def answer(val):
	if d * 10 <= val:
		return 'YES'
	while val > 0:
		if val % d == 0:
			return 'YES'
		val -= 10
	return 'NO'
for t in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		print(answer(i))


for i in range(int(input())):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	if not d:
		d += 10
	dp = [0] * 207
	dp[0] = 1
	mx = d * 10
	for i in range(mx):
		if 10 * i + d <= mx:
			for j in range(mx):
				if 10 * i + d + j <= mx:
					dp[10 * i + d + j] |= dp[j]
	x = 0
	while q:
		q -= 1
		u = a[x]
		x += 1
		if u >= mx or dp[u]:
			print('YES')
		else:
			print('NO')


T = int(input())
for t in range(T):
	(q, d) = tuple([int(x) for x in input().split()])
	aa = [int(x) for x in input().split()]
	end_min = {}
	for i in range(1, 11):
		mult = d * i
		end_digit = mult % 10
		end_min[end_digit] = min(end_min.get(end_digit, 10), mult // 10)
	for a in aa:
		if a >= 10 * d:
			print('YES')
		elif a // 10 >= end_min.get(a % 10, 1000000):
			print('YES')
		else:
			print('NO')


import sys

def answer(q, d, a):
	for e in a:
		if e >= d * 10:
			print('YES')
		elif e == d:
			print('YES')
		elif e < d:
			print('NO')
		elif e % d == 0:
			print('YES')
		elif e in lucky_sets[d]:
			print('YES')
		else:
			print('NO')
	return

def lucky(n, a):
	if str(a) in str(n):
		return True
	else:
		return False

def clsets():
	lucky_sets = [0] * 10
	lucky_sets[0] = set()
	lucky_sets[1] = set()
	lucky_sets[2] = set()
	for i in range(3, 10, 1):
		lucky_sets[i] = set()
		for j in range(i, 10 * i, 1):
			if lucky(j, i) or j - i in lucky_sets[i]:
				lucky_sets[i].add(j)
	return lucky_sets
lucky_sets = clsets()

def main():
	t = int(input())
	while t:
		(q, d) = [int(i) for i in sys.stdin.readline().split()]
		a = [int(i) for i in sys.stdin.readline().split()]
		answer(q, d, a)
		t -= 1
	return
main()


mat = [([11 * d] * 10)[:] for d in range(10)]
for d in range(1, 10):
	unit = d
	started = False
	mat[d][d] = d
	while unit % 10 != 0 or not started:
		started = True
		unit += d
		mat[d][unit % 10] = unit
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	for num in map(int, input().split()):
		unit = num % 10
		if num >= mat[d][unit] or str(d) in str(num):
			print('YES')
		else:
			print('NO')


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(q, d) = inputnums()
	a = inputlist()
	for i in a:
		if i >= d * 10:
			print('YES')
		else:
			p = d
			x = 0
			while p % 10 != i % 10 and x < 11:
				p += d
				x += 1
			if p > i:
				print('NO')
			else:
				print('YES')


t = int(input())
while t > 0:
	(q, d) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:q]
	for i in range(0, q, 1):
		if a[i] >= 10 * d:
			print('YES')
		else:
			l = a[i] % 10
			x = -1
			for j in range(1, 11, 1):
				if d * j % 10 == l:
					x = j
					break
			if x >= 1 and x <= 10:
				if a[i] - x * d >= 0:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
	t = t - 1


import sys
rl = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(int(input())):
	(q, d) = rl()
	A = rl()
	first = []
	for i in range(1, 11):
		first.append(d * i % 10)
	for a in A:
		if len(str(a)) == 1:
			if a % d == 0:
				print('YES')
				continue
			else:
				print('NO')
				continue
		if str(d) in str(a):
			print('YES')
			continue
		if a >= 100:
			print('YES')
			continue
		if int(str(a)[0]) > d:
			print('YES')
			continue
		x = a
		num = x % 100
		c = x % 10
		if c in first:
			a -= d * (first.index(c) + 1)
			if a < 0 or a % 10:
				print('NO')
			else:
				print('YES')
		else:
			print('NO')


prepair = [[0 for i in range(10)] for j in range(10)]

def isLucky(n, d):
	return str(d) in str(n)
for i in range(2, 10):
	for j in range(i, 100):
		if isLucky(j, i):
			mod = j % i
			if prepair[i][mod] == 0:
				prepair[i][mod] = j
test = int(input())
for _ in range(test):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for x in a:
		print('YES' if prepair[d][x % d] <= x else 'NO')


def check_lucky(n, d):
	if n >= 10 * d or n % d == 0:
		return 'YES'
	else:
		for i in range(1, n // d):
			if (n - i * d) % 10 == 0:
				return 'YES'
		return 'NO'
t = int(input())
for _ in range(t):
	qd = input().split()
	q = int(qd[0])
	d = int(qd[1])
	num_list = input().split()
	for item in num_list:
		n = int(item)
		print(check_lucky(n, d))


def check_lucky_num(a, d):
	if a >= d * 10 + d:
		return True
	if a // 10 == d or a % 10 == d:
		return True
	last_digits = []
	for i in range(1, 10):
		last_digits.append(d * i % 10)
	while a > 0:
		for i in range(9):
			if a % 10 == last_digits[i]:
				times = i + 1
				if d * times <= a:
					return True
		a //= 10
	return False

def solve():
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n):
		print('YES' if check_lucky_num(a[i], d) else 'NO')
t = int(input())
for _ in range(t):
	solve()


three = {13, 16, 19, 22, 23, 29, 25, 26, 28}
four = {34, 38, 14, 18, 22, 26, 30}
six = {32, 34, 26, 38, 40, 44, 46, 16, 50, 52, 22, 56, 58, 28}
seven = {17, 24, 27, 31, 34, 37, 38, 41, 44, 45, 47, 48, 51, 52, 54, 55, 57, 58, 59, 61, 62, 64, 65, 66, 68, 69}
eight = {18, 26, 28, 34, 36, 38, 42, 44, 46, 50, 52, 54, 58, 60, 62, 66, 68, 70, 74, 76, 78}
nine = {19, 28, 29, 37, 38, 39, 46, 47, 48, 49, 55, 56, 57, 58, 59, 64, 65, 66, 67, 68, 69, 73, 74, 75, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88}
cases = int(input())
while cases:
	cases -= 1
	(a, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	for num in arr:
		if num % d == 0:
			print('YES')
		elif num >= d * 10:
			print('YES')
		elif str(d) in str(num):
			print('YES')
		elif d == 3 and num in three:
			print('YES')
		elif d == 4 and num in four:
			print('YES')
		elif d == 6 and num in six:
			print('YES')
		elif d == 7 and num in seven:
			print('YES')
		elif d == 8 and num in eight:
			print('YES')
		elif d == 9 and num in nine:
			print('YES')
		else:
			print('NO')


def main():
	num_cases = int(input())
	smallest = [[-1] * 10 for _ in range(10)]
	for d in range(1, 10):
		for mod in range(d):
			while not is_lucky(mod, d):
				mod += d
			smallest[d - 1][mod % d] = mod
	for case_num in range(1, num_cases + 1):
		solve(smallest)

def is_lucky(n, d):
	return str(d) in str(n)

def solve(smallest):
	(q, d) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	for a in A:
		if a < smallest[d - 1][a % d]:
			print('NO')
		else:
			print('YES')
main()


import sys
input = sys.stdin.readline
tmp = [[] for _ in range(10)]
for i in range(2, 10):
	for j in range(1, i * 10):
		ttmp = j
		flag = True
		while ttmp > 0:
			if ttmp % 10 == i:
				flag = False
			ttmp -= i
		if flag:
			tmp[i].append(j)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ls = list(map(int, input().split()))
	for it in ls:
		if it in tmp[m]:
			print('NO')
		else:
			print('YES')


from collections import defaultdict
dp = defaultdict(list)
for i in range(1, 10):
	for j in range(1, 9):
		dp[i].append(i * j)
	val = i + 10
	while val < i * 10:
		dp[i].append(val)
		val += 10
for key in dp:
	i = 0
	while i < len(dp[key]):
		for j in range(0, len(dp[key])):
			for k in range(0, len(dp[key])):
				val = dp[key][j] + dp[key][k]
				if val > key * 10:
					break
				if val not in dp[key]:
					dp[key].append(val)
		i += 1
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	for val in arr:
		if val < d:
			print('NO')
		elif val >= d * 10:
			print('YES')
		elif val in dp[d]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n):
		c = 0
		if a[i] % d == 0:
			c = 1
		else:
			k = 10
			while k > 0 or a[i] > 0:
				temp = a[i]
				if temp % d == 0:
					c = 1
					break
				while temp > 0:
					if temp % 10 == d:
						c = 1
						break
					temp //= 10
				a[i] -= d
				k -= 1
				if c == 1:
					break
		if c == 1:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		x = i % k
		for j in range(i // k + 1):
			if str(k) in str(x):
				print('YES')
				break
			x += k
		else:
			print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	q = list(map(int, input().split()))
	for i in range(n):
		p = q[i]
		am = 'NO'
		for i in range(1, 10):
			if p >= d * i and (p - d * i) % 10 == 0:
				am = 'YES'
		if p < 10 * d:
			print(am)
		else:
			print('YES')


for _ in range(int(input())):
	(q, d) = map(int, input().split(' '))
	nums = list(map(int, input().split(' ')))
	dp = [False for _ in range(10 * d)]
	k = d + 1
	dp[d] = True
	while k < 10 * d:
		if k % 10 == d:
			dp[k] = True
		else:
			dp[k] = dp[k - d]
		k += 1
	for i in range(q):
		if nums[i] >= 10 * d:
			print('YES')
		elif nums[i] == 0:
			print('YES')
		elif nums[i] < d:
			print('NO')
		else:
			print('YES' if dp[nums[i]] else 'NO')


for u in range(int(input())):
	(n, d) = map(int, input().split())
	x = [int(w) for w in input().split()]
	dp = [0] * (10 * d)
	dp[0] = 1
	for i in range(1, 10 * d):
		if str(d) in str(i):
			dp[i] = 1
	for i in range(1, len(dp)):
		if dp[i]:
			continue
		else:
			for j in range(1, i // 2 + 1):
				if dp[j] and dp[i - j]:
					dp[i] = 1
					break
				else:
					continue
	for i in x:
		if i >= 10 * d:
			print('YES')
		elif dp[i]:
			print('YES')
		else:
			print('NO')


import os
import sys
from collections import Counter
from io import BytesIO, IOBase
from math import gcd, inf, sqrt

def lcm(a, b):
	return a * b // gcd(a, b)

def getFactorization(x):
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def printDivisors(n):
	i = 2
	z = [1, n]
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				z.append(i)
			else:
				z.append(i)
				z.append(n // i)
		i = i + 1
	return z

def cheaker(a):
	j = 1
	p = False
	for i in a:
		if i != j:
			break
		j += 1
	q = len(a)
	for i in a[::-1]:
		if i != q:
			break
		q -= 1
	for i in range(j - 1, q):
		if a[i] == i + 1:
			return False
	return True

def create(n, x, f):
	pq = len(bin(n)[2:])
	if f == 0:
		tt = min
	else:
		tt = max
	dp = [[inf] * n for _ in range(pq)]
	dp[0] = x
	for i in range(1, pq):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def enquiry(l, r, dp, f):
	if l > r:
		return inf if not f else -inf
	if f == 1:
		tt = max
	else:
		tt = min
	pq1 = len(bin(r - l + 1)[2:]) - 1
	return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	x = []
	for i in range(2, n + 1):
		if prime[i]:
			x.append(i)
	return x

def fun1(a):
	for i in range(len(a)):
		print('YES')

def fun2(a):
	for i in range(len(a)):
		if a[i] >= 21:
			print('YES')
		elif a[i] % 2 == 0:
			print('YES')
		else:
			print('NO')

def fun3(a):
	for i in range(len(a)):
		if a[i] >= 31:
			print('YES')
		elif a[i] % 3 == 0:
			print('YES')
		else:
			print('NO')

def main():
	for i in range(int(input())):
		(q, d) = map(int, input().split())
		a = [int(x) for x in input().split()]
		for ii in a:
			if ii % d == 0:
				print('YES')
			elif ii >= d * 10:
				print('YES')
			else:
				flag = False
				for p in range(d, ii + 1, d):
					if ii % p == 0 or (ii - p) % 10 == 0:
						flag = True
				if flag:
					print('YES')
				else:
					print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


tc = int(input())
for _ in range(tc):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	good = [False] * 100
	good[0] = True
	for k in range(100):
		if k % 10 == d or k // 10 == d:
			for s in range(100 - k):
				if good[s]:
					good[s + k] = True
	for e in a:
		if e >= 100 or good[e]:
			print('YES')
		else:
			print('NO')


import sys

def fn(n, d, a):
	dp = [0] * (100 + 1)
	for i in range(100 + 1):
		k = i
		while k > 0:
			r = k % 10
			if r == d:
				dp[i] = 1
				break
			k = k // 10
	dp[d] = 1
	for i in range(100 + 1):
		if i > d and dp[i - d] == 1:
			dp[i] = 1
	for i in range(n):
		if a[i] > 100:
			print('YES')
			continue
		if dp[a[i]] == 1:
			print('YES')
			continue
		else:
			print('NO')
			continue
input = sys.stdin.read()
data = list(map(int, input.split()))
t = data[0]
l = 0
for i in range(t):
	n = data[l + 1]
	d = data[l + 2]
	a = data[l + 3:l + n + 3]
	l = l + 2 + n
	fn(n, d, a)


def is_d(n, d):
	while n:
		if n % 10 == d:
			return True
		n //= 10
	return False
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	size = 10 * d + 1
	dp = [False] * size
	dp[0] = True
	for i in range(1, len(dp)):
		if i < d:
			continue
		elif i == d or i % d == 0 or is_d(i, d) or dp[i - d]:
			dp[i] = True
	for i in range(n):
		if a[i] >= size:
			print('YES')
		elif dp[a[i]] == True:
			print('YES')
		else:
			print('NO')


class Solution:

	def solve(self, q, d):
		n = len(q)
		for i in range(n):
			if q[i] >= d * 10:
				print('YES')
			elif d == 1:
				print('YES')
			elif q[i] % 10 == d:
				print('YES')
			elif q[i] % d == 0:
				print('YES')
			else:
				result = self.is_lucky(q[i], d)
				print(result)

	def is_lucky(self, num, d):
		while True:
			if num < d:
				return 'NO'
			if num % d == 0:
				return 'YES'
			num -= 10
sol = Solution()
tests = int(input())
for i in range(tests):
	(_, d) = list(map(int, input().split()))
	q = list(map(int, input().split()))
	sol.solve(q, d)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(q, d) = map(int, sys.stdin.readline().split())
	ls = list(map(int, sys.stdin.readline().split()))
	for num in ls:
		ans = 'NO'
		if num >= d * 10:
			ans = 'YES'
		else:
			for key in range(num, 0, -10):
				if key % d == 0:
					ans = 'YES'
					break
		print(ans)


t = int(input())
for _ in range(t):
	(q, d) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	poss = [False] * 1001
	for i in range(1001):
		if str(d) in str(i):
			poss[i] = True
	for i in range(110):
		if poss[i]:
			for j in range(110):
				if poss[j] and i + j <= 110:
					poss[i + j] = True
	for query in l:
		if query > 110 or poss[query]:
			print('YES')
		else:
			print('NO')


import sys, collections, math, itertools, random, bisect
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = int(1000000000.0 + 7)

def solve(n, d):
	while n > 0:
		if n % 10 == d:
			return True
		n //= 10
	return False
for _ in range(int(input())):
	(n, d) = get_ints()
	arr = get_array()
	for c in arr:
		while c > 0 and (not solve(c, d)):
			c -= d
		if c > 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(n):
		m = l[i] % d
		if l[i] > d * 10 + m:
			print('YES')
		else:
			(a, f) = (l[i], 0)
			while a > 0:
				if str(d) in str(a):
					f = 1
					break
				a -= d
			if f == 1:
				print('YES')
			else:
				print('NO')


for t in range(int(input())):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	chk = []
	for i in range(1, 11):
		chk.append(d * i)
	for i in arr:
		if i >= d * 10:
			print('YES')
			continue
		d2 = i % 10
		flag = 0
		number = 0
		for j in chk:
			if j % 10 == d2:
				number = j
				flag = 1
				break
		if flag == 1 and number <= i:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(n, k) = invr()
	a = inara()
	dp = [0] * 1000
	dp[k] = 1

	def good(x):
		while x:
			if x % 10 == k:
				return True
			x //= 10
		return False
	for i in range(k + 1, 1000):
		if good(i):
			dp[i] = 1
		elif dp[i - k] == 1:
			dp[i] = 1
	for i in a:
		if i >= 1000:
			print('YES')
		elif dp[i]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = input().split()
	d = {}
	for i in c:
		f = 0
		if i in d:
			print(d[i])
			f = 1
			continue
		for j in range(10):
			if int(i) >= b * 10:
				d[i] = 'YES'
				print('YES')
				f = 1
				break
			elif int(i) - b * j <= 0:
				d[i] = 'NO'
				print('NO')
				f = 1
				break
			elif str(b) in str(int(i) - b * j):
				d[i] = 'YES'
				print('YES')
				f = 1
				break
		if f == 0:
			d[i] = 'NO'
			print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		p = 0
		h = 0
		while h <= i:
			if str(i - h).count(str(k)) > 0:
				p = 1
				print('YES')
				break
			h += k
		if p == 0:
			print('NO')


def readInt():
	return int(input())

def readInts():
	return [int(x) for x in input().split()]

def readString():
	return input().rstrip()

def readCase():
	return readString()
lucky_mod = [[0 for _ in range(n)] for n in range(10)]
luckys = [set() for _ in range(10)]
for d in range(2, 10):
	d_str = str(d)
	x = 1
	found = 0
	while found < d:
		if str(x).find(d_str) != -1:
			mod = x % d
			if lucky_mod[d][mod] == 0:
				found += 1
				luckys[d].add(x)
				lucky_mod[d][mod] = x
		x += 1

def solve(q, d, numbers):
	result = []
	for n in numbers:
		if n in luckys[d]:
			result.append('YES')
		else:
			sub = lucky_mod[d][n % d]
			if n < sub:
				result.append('NO')
			else:
				result.append('YES')
	return result
cases = readInt()
for case in range(cases):
	(q, d) = readInts()
	numbers = readInts()
	for x in solve(q, d, numbers):
		print(x)


t = int(input())
for t in range(t):
	(p, q) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst1 = []
	for i in range(1, 10):
		q1 = q * i % 10
		lst1.append(q1)
	lst1.append(0)
	for i in range(len(lst)):
		if lst[i] >= q * 10:
			print('YES')
		elif lst[i] % 10 in lst1:
			q1 = lst[i] % 10
			if (lst1.index(q1) + 1) * q <= lst[i]:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(len(A)):
		if A[i] >= 10 * m:
			print('YES')
		else:
			while A[i] > 0 and A[i] % 10 != m:
				A[i] -= m
			if A[i] % 10 == m and A[i] > 0:
				print('YES')
			else:
				print('NO')


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
t = 1
t = int(input())
while t:
	t -= 1
	(q, d) = list(map(int, input().split()))
	a = list(input().strip().split())
	one = set([])
	for i in range(1, 10):
		one.add(i * d)
	ans = False
	for el in a:
		val = int(el)
		if val >= d * 11:
			print('YES')
			continue
		if str(d) in el:
			print('YES')
			continue
		for mult in one:
			if val < mult:
				continue
			if (val - mult) % 10 == 0:
				ans = True
				break
		if ans:
			print('YES')
			ans = False
			continue
		print('NO')


t = int(input())
for _ in range(t):
	(q, d) = map(int, input().split())
	a_list = list(map(int, input().split()))
	for a in a_list:
		if a >= 10 * d:
			print('YES')
			continue
		a_new = a
		while a_new >= d:
			if a_new % 10 == d:
				print('YES')
				break
			a_new -= d
		else:
			print('NO')


def ans(x, d, l):
	try:
		t = l.index(x % 10)
	except:
		if x > d * 10:
			return 'YES'
		else:
			return 'NO'
	if d * t <= x:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(t):
	(q, d) = [int(i) for i in input().strip().split()]
	a = [int(i) for i in input().strip().split()]
	l = [-1]
	for i in range(1, 11):
		l.append(d * i % 10)
	for x in a:
		print(ans(x, d, l))


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(val)
	sys.stdout.write('\n')
for _ in range(int(input())):
	(q, d) = map(int, input().split())
	qs = list(map(int, input().split()))
	out = []
	for a in qs:
		if a >= d * 10 + d or d == a // 10:
			out.append('YES')
		else:
			worked = False
			while a > 0:
				if a % d == 0:
					worked = True
					break
				a -= 10
			out.append('YES' if worked else 'NO')
	print('\n'.join(out))


def hasDigit(x, d):
	while x > 0:
		q = x % 10
		if q == d:
			return True
		x //= 10
	return False
t = int(input())
while t > 0:
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	p = [False] * 100
	for i in range(1, 100):
		if hasDigit(i, d):
			p[i] = True
		else:
			for j in range(1, i):
				if p[j] and p[i - j]:
					p[i] = True
	for x in l:
		if x >= 100 or p[x]:
			print('YES')
		else:
			print('NO')
	t -= 1


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	limits = {}
	for i in range(d, 10 * d, 10):
		if i % d not in limits.keys():
			limits[i % d] = i - d
	for i in range(d):
		if i not in limits.keys():
			limits[i] = 10 * d - 1
	for n in map(int, input().split()):
		mod = n % d
		if n <= limits[mod]:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	for i in range(n):
		res = 'NO'
		while arr[i] > 0:
			if str(d) in str(arr[i]):
				res = 'YES'
				break
			else:
				arr[i] = arr[i] - d
		print(res)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		t = inp()
		for _ in range(t):
			(q, d) = invr()
			numbers = {}
			for j in range(1, 11):
				last_d = int(str(j * d)[-1])
				if last_d in numbers:
					break
				else:
					numbers[last_d] = j * d
			a = inlt()
			for i in range(q):
				if a[i] >= d * 10 or a[i] % d == 0:
					print('YES')
					continue
				last_digit = int(str(a[i])[-1])
				if last_digit in numbers and a[i] >= numbers[last_digit]:
					print('YES')
				else:
					val = list(str(a[i]))
					if d in val:
						print('YES')
					else:
						print('NO')
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def number():
	return int(input())

def numbers():
	return [int(item) for item in input().split()]

def make(n):
	res = []
	for i in range(1, 11):
		for j in range(n * i, n * 10 + 1, 10):
			res.append(j)
	res = list(set(res))
	res.sort()
	return res
table = [make(i) for i in range(1, 10)]

def f(d, item):
	t = table[d - 1]
	return item >= t[-1] or item in t
for i in range(number()):
	(q, d) = numbers()
	for item in numbers():
		print('YES' if f(d, item) else 'NO')


def generate_result():
	t = int(input())
	ret = []
	for _ in range(t):
		(q, d) = map(int, input().split())
		if d == 2 or d == 5:
			for a in map(int, input().split()):
				if a >= d * 10 or a % d == 0:
					yield 'YES'
				else:
					yield 'NO'
		else:
			if d % 2 == 0:
				b = d * 10 - 1
			else:
				b = d * 10 - 10
			for a in map(int, input().split()):
				if a > b:
					yield 'YES'
				else:
					while a > 0:
						if a % d == 0:
							yield 'YES'
							break
						else:
							a -= 10
					else:
						yield 'NO'

def main():
	print('\n'.join(generate_result()))
main()


import sys

def main():
	test_cases = int(sys.stdin.readline())
	for _ in range(test_cases):
		(N, D) = (int(i) for i in sys.stdin.readline().split())
		A = [int(i) for i in sys.stdin.readline().split()]
		limit = 10 * D
		T = [D + i * 10 for i in range(D)]
		B = set([0])
		while limit not in B:
			B0 = set()
			for b in B:
				for t in T:
					if b + t <= limit:
						B0.add(b + t)
			B.update(B0)
		for a in A:
			if a >= limit:
				print('YES')
			elif a in B:
				print('YES')
			else:
				print('NO')
main()


def yes(n, d):
	if n > 10 * d:
		return 'YES'
	while n >= d:
		if not (n := (n - d)) % 10:
			return 'YES'
	return 'NO'
for x in range(int(input())):
	d = int(input().split()[1])
	for n in map(int, input().split()):
		print(yes(n, d))


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	num = [[1], [2, 21], [3, 13, 23], [4, 41, 14, 43], [5, 51, 52, 53, 54], [6, 61, 26, 63, 16, 65], [7, 57, 37, 17, 67, 47, 27], [8, 81, 18, 83, 28, 85, 38, 87], [9, 19, 29, 39, 49, 59, 69, 79, 89]]
	for i in l:
		if str(d) in str(i) or d == 1:
			print('YES')
		else:
			x = i % d
			if i >= num[d - 1][x]:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	(q, d) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	ans = [10 ** 18 for i in range(d)]
	x = d
	for i in range(10):
		m = x % d
		if ans[m] == 10 ** 18:
			ans[m] = x
		x += 10
	x = 10 * d
	for i in range(10):
		m = x % d
		if ans[m] == 10 ** 18:
			ans[m] = x
		x += 1
	for i in range(q):
		m = arr[i] % d
		if arr[i] >= ans[m]:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	for j in range(q):
		y = l[j]
		while str(d) not in str(y) and y > 0:
			y -= d
		if str(d) in str(y):
			print('YES')
		else:
			print('NO')


maxn = 207

def solve(q, d, a, anss):
	dp = [False] * maxn
	dp[0] = True
	if d == 0:
		d = 10
	mx = 10 * d
	i = 0
	while 10 * i + d <= mx:
		j = 0
		while True:
			p = 10 * i + d + j
			if p > mx:
				break
			dp[p] = dp[p] or dp[j]
			j += 1
		i += 1
	for u in a:
		anss.append('YES' if u >= mx or dp[u] else 'NO')

def main():
	t = int(input())
	anss = []
	for i in range(t):
		(q, d) = map(int, input().split())
		a = list(map(int, input().split()))
		solve(q, d, a, anss)
	for ans in anss:
		print(ans)
main()


n = int(input())
for _ in range(n):
	(q, d) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	if d == 1:
		for _ in range(len(arr)):
			print('YES')
		continue
	for i in arr:
		dd = 0
		z = i
		while dd < 50 * d and dd < i:
			if str(d) in str(z):
				print('YES')
				break
			else:
				dd += d
			z = i - dd
		else:
			print('NO')


def solve(d, a):
	if a > d * 10:
		return 'YES'
	if a % 10 == d:
		return 'YES'
	while a > 0:
		if a % 10 == d:
			return 'YES'
		a -= d
	return 'NO'

def main():
	ans = []
	t = int(input())
	for _ in range(t):
		(q, d) = map(int, input().split(' '))
		A = list(map(int, input().split(' ')))
		for a in A:
			ans.append(solve(d, a))
	for a in ans:
		print(a)
main()


t = int(input())
for cases in range(t):
	(q, d) = map(int, input().split())
	nos = list(map(int, input().split()))
	for n in nos:
		if str(d) in str(n):
			print('YES')
		elif n % d == 0:
			print('YES')
		else:
			temp = n
			check = False
			while temp > d:
				if str(d) in str(temp - d):
					print('YES')
					check = True
					break
				temp = temp - d
			if check == False:
				print('NO')


for _ in range(int(input())):
	(t, d) = map(int, input().split())
	for n in list(map(int, input().split())):
		flag = False
		while n >= 0:
			if str(d) in str(n):
				flag = True
				break
			n -= d
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	l = [int(x) for x in input().split()]
	x = d * 10
	for ele in l:
		if ele < x:
			while ele > 0 and ele % 10 != d:
				ele -= d
			if ele <= 0:
				print('NO')
			else:
				print('YES')
		else:
			print('YES')


def create(arr, v):
	x = len(arr)
	dp = [[0 for i in range(v)] for j in range(x + 1)]
	for i in range(x + 1):
		dp[i][0] = 1
	for i in range(x + 1):
		for j in range(v):
			if arr[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i][j - arr[i - 1]]
	for i in arr:
		dp[x][i] = 1
	return dp

def inl():
	return [int(i) for i in input().split()]

def inp():
	return int(input())
for _ in range(inp()):
	(q, d) = inl()
	v = 10 * d
	a = inl()
	arr = []
	for i in range(d):
		arr.append(d + 10 * i)
	dp = create(arr, v)
	x = len(arr)
	for i in range(v):
		if dp[x][i] and i not in arr:
			arr.append(i)
	dp = create(arr, v)
	x = len(dp) - 1
	for i in a:
		if i < v:
			if dp[x][i]:
				print('YES')
			else:
				print('NO')
		else:
			print('YES')


def Solve():
	(qs, ds, A) = ([], [], [])
	for t in range(int(input())):
		(q, d) = map(int, input().split())
		qs.append(q)
		ds.append(d)
		A.append(list(map(int, input().split())))
	for (q, d, a) in zip(qs, ds, A):
		for i in a:
			while 0 < i < 10 * d and i % d != 0:
				i -= 10
			if i < d:
				print('NO')
			else:
				print('YES')
Solve()


from sys import stderr

def dbp(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def get_int_list():
	return [int(i) for i in input().strip().split()]

def gen_lucky_pile(d, maxx):
	lp = set()
	dstr = str(d)
	maxx += 1
	for i in range(maxx):
		if dstr in str(i):
			lp.add(i)
	klist = list(lp)
	for k in klist:
		if k == 0:
			continue
		i = 2
		while i * k < maxx:
			lp.add(i * k)
			i += 1
	maxl = -1
	while len(lp) > maxl:
		maxl = len(lp)
		klist = list(lp)
		for k in klist:
			for j in klist:
				if k + j < maxx:
					lp.add(k + j)
	return lp
piles = {}
maxfails = {}
for d in range(10):
	lp = gen_lucky_pile(d, 100)
	maxfail = None
	for i in range(100 + 1):
		if i not in lp:
			maxfail = i
	piles[d] = lp
	maxfails[d] = maxfail

def do_thing():
	(_, d) = get_int_list()
	alist = get_int_list()
	ans = []
	for a in alist:
		if a > maxfails[d] or a in piles[d]:
			ans.append('YES')
		else:
			ans.append('NO')
	return '\n'.join(ans)
maxcc = int(input().strip())
for cc in range(maxcc):
	print(do_thing())


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	(values, scale) = ([int(i) for i in input().split()], 10 * d)
	dp = [0 for i in range(scale + 1)]
	(dp[0], i) = (1, 0)
	while 10 * i + d <= scale:
		j = 0
		while 10 * i + j + d <= scale:
			dp[10 * i + j + d] = max(dp[10 * i + j + d], dp[j])
			j += 1
		i += 1
	for i in range(q):
		if values[i] >= scale or dp[values[i]]:
			print('YES')
		else:
			print('NO')


from collections import defaultdict as dd
lim = 10 ** 4 + 1
dp = [[0] * lim for i in range(10)]
for j in range(1, lim):
	dp[1][j] = 1
last = [0, 1] + [0] * 8

def find(num, dig):
	while num:
		if num % 10 == dig:
			return True
		num = num // 10
	return False
for digit in range(2, 10):
	pos = [0] * digit
	pos[0] = 1
	for num in range(1, lim):
		if find(num, digit) or pos[num % digit]:
			dp[digit][num] = 1
		pos[num % digit] = max(pos[num % digit], dp[digit][num])
		if sum(pos) == digit:
			last[digit] = num
			break
for case in range(int(input())):
	(q, d) = map(int, input().split())
	arr = map(int, input().split())
	for it in arr:
		if it > last[d] or dp[d][it]:
			print('YES')
		else:
			print('NO')


T = int(input())
for t in range(T):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	vis = [0 for it in range(10)]
	mi = [0 for it in range(10)]
	now = m
	res = m
	while not vis[now]:
		vis[now] = 1
		mi[now] = res
		res += m
		now = (now + m) % 10
	for i in range(n):
		if a[i] >= 10 * m:
			print('YES')
		else:
			pos = a[i] % 10
			if not vis[pos]:
				print('NO')
			elif a[i] >= mi[pos]:
				print('YES')
			else:
				print('NO')


t = int(input())
for i in range(t):
	(q, d) = list(map(int, input().strip().split()))
	nums = []
	dp = [False] * (10 * d)
	dp[0] = True
	for j in range(10):
		nums.append(j * 10 + d)
	for j in range(10):
		for k in range(nums[j], 10 * d):
			dp[k] |= dp[k - nums[j]]
	a = list(map(int, input().strip().split()))
	for j in range(q):
		if a[j] >= 10 * d or dp[a[j]]:
			print('YES')
		else:
			print('NO')


from sys import stdin
input = stdin.readline

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def f(x, m):
	a = str(x)
	k = str(m)
	for i in a:
		if i == k:
			return 1
	return 0
tc = int(input())
p = {}
for i in range(1, 10):
	p[i] = [i]
for i in range(1, 10):
	for j in range(1, i):
		x = i * 10 + j
		y = x
		while x > 0:
			if f(x, i):
				y = x
			x -= i
		p[i].append(y)
for _ in range(tc):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		if i >= p[d][i % d]:
			print('YES')
		else:
			print('NO')


def solve():
	(nn, d) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		while True:
			if i < 0:
				print('NO')
				break
			elif str(i).find(str(d)) != -1:
				print('YES')
				break
			else:
				i = i - d
for testis in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	for val in arr:
		flag = 0
		if val % d == 0 or val >= 10 * d:
			print('YES')
		elif val < d:
			print('NO')
		else:
			for i in range(d, 10 * d + 1, d):
				if i % 10 == val % 10 and i <= val:
					print('YES')
					flag = 1
					break
			if flag == 0:
				print('NO')


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
from statistics import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	(q, d) = ipl()
	a = ipl()
	l = []
	i = 0
	if not d:
		d += 10
	while d + 10 * i <= d * 10:
		l.append(d + 10 * i)
		i += 1
	dp = {}

	def sol(i, t):
		if (i, t) in dp:
			return dp[i, t]
		if t == 0:
			return True
		if i == len(l) or t < 0:
			return False
		dp[i, t] = sol(i, t - l[i]) or sol(i + 1, t)
		return dp[i, t]
	for i in a:
		print('YES' if (True if i >= d * 10 else sol(0, i)) else 'NO')
for _ in range(ipn()):
	solve()


import sys, collections, math, itertools, random, bisect
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(q, d) = get_ints()
	a = get_array()
	for i in range(q):
		if str(d) in str(a[i]):
			print('YES')
		else:
			rem = a[i] % d
			flag = False
			x = 0
			while x < 11 * d and x <= a[i]:
				if x + rem <= a[i] and str(d) in str(x + rem):
					flag = True
					break
				else:
					x += d
			if flag:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		f = 0
		while str(i).count(str(d)) < 1:
			i = i - d
			if i < 1:
				i = i + d
				if str(i).count(str(d)) > 0:
					f = 1
					print('YES')
					break
				else:
					f = 1
					print('NO')
					break
		if str(i).count(str(d)) > 0 and f == 0:
			print('YES')
		elif f == 0:
			print('NO')


import math

def bruteForce(num):
	sol = []
	for i in range(num):
		sol.append(num + i * 10)
	numIter = num
	while numIter < num * 10:
		for i in range(num):
			if numIter + sol[i] < num * 10:
				sol.append(numIter + sol[i])
		numIter += num
	return list(set(sol))
nbTests = int(input())
for k in range(nbTests):
	nnum = input().split()
	(n, num) = (int(nnum[0]), int(nnum[1]))
	T = list(map(int, input().split()))
	sol = bruteForce(num)
	for toTest in T:
		if toTest >= num * 10:
			print('YES')
		elif toTest in sol:
			print('YES')
		else:
			print('NO')


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7

def ok():
	if a > d * 10:
		return True
	now = a
	while now > 0:
		if now % 10 == d:
			return True
		now -= d
	return False
for _ in range(II()):
	(q, d) = MI()
	for a in MI():
		print('YES' if ok() else 'NO')


for x in range(int(input())):
	(q, d) = map(int, input().split())
	data = list(map(int, input().split()))
	dp = [False] * (10 * d)
	dp[d] = True
	length = d + 1
	steps = [d]
	for i in range(d, 10 * d):
		if str(d) in str(i):
			dp[i] = True
			steps.append(i)
			continue
		for j in steps:
			if dp[i - j]:
				dp[i] = True
			break
	for _ in data:
		print('YES') if _ >= 10 * d or dp[_] else print('NO')


def lucky(n, d):
	temp = d * 10
	if n >= temp:
		return 'YES'
	if d == 1:
		return 'YES'
	if n % d == 0:
		return 'YES'
	for i in range(9):
		t = d * (i + 1)
		if t > n:
			return 'NO'
		if (n - t) % 10 == 0:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(q, d) = input().split()
	q = int(q)
	d = int(d)
	a = [int(x) for x in input().split()]
	for i in a:
		print(lucky(i, d))


def solve(it, d):
	if it >= 10 * d:
		return 'YES'
	remain = it % d
	if remain == 0:
		return 'YES'
	while remain < 100:
		remain += d
		if remain >= it:
			return 'NO'
		if remain % 10 == 0:
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	(__, d) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	for it in a:
		print(solve(it, d))


def good(d, i):
	x = i // d * d
	while x >= 0:
		if str(i - x).count(str(d)):
			return 'YES'
		x -= d
	return 'NO'
for i in range(int(input())):
	(n, d) = map(int, input().strip().split())
	lst = list(map(int, input().strip().split()))
	for v in lst:
		print(good(d, v))


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	qs = list(map(int, input().split()))
	for a in qs:
		if a >= d * 10 + d or d == a // 10:
			print('YES')
		else:
			worked = False
			while a >= 0:
				a -= d
				if a % 10 == 0:
					worked = True
					break
			print('YES' if worked else 'NO')


import sys
import math
import random
from queue import PriorityQueue as PQ
from bisect import bisect_left as BSL
from bisect import bisect_right as BSR
from collections import OrderedDict as OD
from collections import Counter
from itertools import permutations
mod = 1000000007
MOD = mod
try:
	sys.stdin = open('actext.txt', 'r')
	OPENFILE = 1
except:
	pass

def get_ints():
	return map(int, input().split())

def palindrome(s):
	mid = len(s) // 2
	for i in range(mid):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True

def check(i, n):
	if 0 <= i < n:
		return True
	else:
		return False
t = int(input())
for tt in range(t):
	(q, d) = get_ints()
	arr = list(get_ints())
	cutoff = d * 10
	for i in arr:
		if i >= cutoff:
			print('YES')
		else:
			flg = 0
			rem = i // d + 1
			for j in range(rem, 0, -1):
				if (i - j * d) % 10 == 0:
					flg = 1
			if flg == 1:
				print('YES')
			else:
				print('NO')


from pprint import pprint
import sys
input = sys.stdin.readline

def do():
	(q, d) = map(int, input().split())
	dat = list(map(int, input().split()))
	for x in dat:
		can = False
		for i in range(110):
			if x < d or x < 0:
				break
			if str(x).count(str(d)) != 0:
				can = True
				break
			x -= d
		if can:
			print('YES')
		else:
			print('NO')
q = int(input())
for _ in range(q):
	do()


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(q):
		while True:
			if str(d) in str(l[i]):
				print('YES')
				break
			else:
				l[i] -= d
				if l[i] < d:
					print('NO')
					break


def solve():
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for x in a:
		if x % d == 0 or x > d * 10:
			print('YES')
		else:
			op = x % 10
			temp = d
			while temp < x:
				if temp % 10 == x % 10:
					break
				temp += d
			if temp <= x:
				print('YES')
			else:
				print('NO')
for _ in range(int(input())):
	solve()


for t in range(0, int(input())):
	(q, d) = tuple(map(int, input().split()))
	nums = list(map(int, input().split()))
	check = {}
	for x in range(1, 11):
		r = x * d % 10
		if r not in check:
			check[r] = x
	for i in nums:
		if d == 1 or i >= d * 10:
			print('YES')
		else:
			y = i % 10
			z = i // d
			if y in check and check[y] <= z:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	box = []
	j = 0
	flag = 0
	for i in range(n):
		flag = 0
		if a[i] > k * 10:
			print('YES')
		else:
			j = a[i]
			while j >= k:
				if j % k == 0:
					print('YES')
					flag = 1
					break
				j -= 10
			if flag == 0:
				print('NO')


import collections
import math
from heapq import *
k = {}
k[2] = set([1, 3, 5, 7, 9, 11, 13, 15, 17, 19])
k[3] = set([1, 2, 4, 5, 7, 8, 10, 11, 14, 17, 20])
k[4] = set([1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])
k[5] = set([1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49])
k[6] = set([1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 17, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])
k[7] = set([1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 18, 19, 20, 22, 23, 25, 26, 29, 30, 32, 33, 36, 39, 40, 43, 46, 50, 53, 60])
k[8] = set([1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 19, 20, 21, 22, 23, 25, 27, 29, 30, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79])
k[9] = set([1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 25, 26, 30, 31, 32, 33, 34, 35, 40, 41, 42, 43, 44, 50, 51, 52, 53, 60, 61, 62, 70, 71, 80])
for t in range(int(input())):
	(q, d) = map(int, input().split())
	nums = map(int, input().split())
	for i in nums:
		if d == 1 or i % d == 0 or i % 10 == d:
			print('YES')
		elif i in k[d]:
			print('NO')
		else:
			print('YES')


from functools import lru_cache

class Solution:

	def minimumSize(self):
		t = int(input())
		while t >= 1:
			(q, d) = map(int, input().split())
			arr = list(map(int, input().split()))
			for i in range(len(arr)):
				if arr[i] >= 10 * d:
					print('YES')
					continue
				else:
					number = arr[i]
					isLucky = False
					while number > 0:
						if number % 10 == d:
							print('YES')
							isLucky = True
							break
						number -= d
					if not isLucky:
						print('NO')
			t -= 1
s = Solution()
s.minimumSize()


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	f = [0] * 256
	f[0] = 1
	for i in range(128):
		if f[i]:
			f[i + d] = 1
			for x in range(10):
				f[i + d * 10 + x] = 1
				f[i + x * 10 + d] = 1
	for x in map(int, input().split()):
		if x < d * 10:
			print('YES' if f[x] else 'NO')
		else:
			print('YES')


import sys
import math
t = int(input().strip())
for a0 in range(t):
	l = [int(i) for i in input().split()]
	q = l[0]
	d = l[1]
	l1 = [int(i) for i in input().split()]
	c = 0
	flg = 0
	a = str(d) + '0'
	a = int(a)
	b = str(d)
	m = []
	for i in l1:
		flg = 0
		if i >= a:
			print('YES')
		else:
			while i > 0:
				if str(i).count(b) >= 1:
					flg = 1
					print('YES')
					break
				i -= d
			if flg == 0:
				print('NO')


I = lambda : [*map(int, input().split())]
(t,) = I()
for _ in ' ' * t:
	(n, k) = I()
	l = I()
	a = [1000000000.0 + 1] * 10
	for i in range(10, 0, -1):
		a[k * i % 10] = i * k
	for i in l:
		print('YNEOS'[i < k * 10 and a[i % 10] > i::2])


from collections import Counter
d1 = {7: 1, 4: 2, 1: 3, 8: 4, 5: 5, 2: 6, 9: 7, 6: 8, 3: 9, 0: 10}
d2 = {3: 1, 6: 2, 9: 3, 2: 4, 5: 5, 8: 6, 1: 7, 4: 8, 7: 9, 0: 10}
d3 = {9: 1, 8: 2, 7: 3, 6: 4, 5: 5, 4: 6, 3: 7, 2: 8, 1: 9, 0: 10}
d4 = {2: 1, 4: 2, 6: 3, 8: 4, 0: 5}
d6 = {6: 1, 2: 2, 8: 3, 4: 4, 0: 5}
d5 = {4: 1, 8: 2, 2: 3, 6: 4, 0: 5}
d7 = {8: 1, 6: 2, 4: 3, 2: 4, 0: 5}
t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	if d == 1:
		for i in l:
			print('YES')
	elif d == 5:
		for i in range(len(l)):
			s = str(l[i])
			k = int(s[len(s) - 1])
			if str(d) in s:
				print('YES')
			elif l[i] > d * 10:
				print('YES')
			elif k == 5 or k == 0:
				print('YES')
			else:
				print('NO')
	elif d % 2 != 0:
		for i in range(n):
			s = str(l[i])
			k = s[len(s) - 1]
			if str(d) in s:
				print('YES')
			elif d == 3:
				if 3 * d2[int(k)] > l[i]:
					print('NO')
				else:
					print('YES')
			elif d == 7:
				if 7 * d1[int(k)] > l[i]:
					print('NO')
				else:
					print('YES')
			elif 9 * d3[int(k)] > l[i]:
				print('NO')
			else:
				print('YES')
	else:
		for i in range(n):
			s = str(l[i])
			k = int(s[len(s) - 1])
			if str(d) in s:
				print('YES')
			elif l[i] > d * 10:
				print('YES')
			elif k % 2 == 0:
				if d == 2:
					if 2 * d4[k] > l[i]:
						print('NO')
					else:
						print('YES')
				elif d == 4:
					if 4 * d5[k] > l[i]:
						print('NO')
					else:
						print('YES')
				elif d == 6:
					if 6 * d6[k] > l[i]:
						print('NO')
					else:
						print('YES')
				elif 8 * d7[k] > l[i]:
					print('NO')
				else:
					print('YES')
			else:
				print('NO')


def mas(d):
	a = []
	for i in range(d, d * 10, 10):
		for j in range(0, d * 10, d):
			a.append(i + j)
	return a
for i in range(int(input())):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	b = mas(d)
	b.sort()
	for j in range(len(a)):
		if a[j] not in b and a[j] < d * 10:
			print('NO')
		else:
			print('YES')


for i in range(int(input())):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	if d == 1:
		for j in range(q):
			print('YES')
	else:
		for f in range(q):
			b = l[f]
			c = 0
			while b >= d:
				if str(d) in str(b):
					c = 1
					print('YES')
					break
				else:
					b -= d
			if c == 0:
				print('NO')


for i in range(int(input())):
	fl = list(map(int, input().split()))
	(q, d) = (fl[0], fl[1])
	a = list(map(int, input().split()))
	last_digits = dict()
	for i in range(1, 11):
		last_digits[i] = d % 10 * (i % 10) % 10
	for num in a:
		g = 0
		if num > d * 10:
			print('YES')
			g = 1
		elif num % d == 0:
			print('YES')
			g = 1
		else:
			ld = num % 10
			low_divisor = num // d
			for i in range(1, low_divisor + 1):
				if last_digits[i] == ld:
					print('YES')
					g = 1
					break
		if g == 0:
			print('NO')


def luckyNumbers(n, k, array):
	ans = []
	s = []
	for x in range(10):
		s.append(k * (x + 1))
	for x in array:
		if x > s[-1]:
			ans.append('YES')
		else:
			flag = 0
			for i in s:
				if x >= i and x % 10 == i % 10:
					flag = 1
					ans.append('YES')
					break
			if flag == 0:
				ans.append('NO')
	return ans
t = int(input())
final = []
for _ in range(t):
	(n, k) = map(int, input().split())
	l = map(int, input().split())
	final.append(luckyNumbers(n, k, l))
for _ in range(t):
	for x in final[_]:
		print(x)


for _ in range(int(input())):
	(n, d) = input().split()
	for i in input().split():
		i = int(i)
		while i > 0:
			if d in str(i):
				print('YES')
				break
			else:
				i -= int(d)
		else:
			print('NO')


def main():
	import sys
	input = lambda : sys.stdin.readline()[:-1]
	dp = [[0] * 100 for _ in range(10)]

	def precomp():

		def lucky(d, n):
			s = str(n)
			t = str(d)
			return t in s
		for d in range(1, 10):
			dp[d][0] = 1
			for i in range(1, 100):
				for j in range(1, i + 1):
					if dp[d][i - j] and lucky(d, j):
						dp[d][i] = 1
						break
	precomp()

	def helper(d, n):
		if n >= 100:
			return True
		return dp[d][n]

	def solve():
		(q, d) = map(int, input().split())
		arr = list(map(int, input().split()))
		for i in range(q):
			if helper(d, arr[i]):
				print('YES')
			else:
				print('NO')
	for _ in range(int(input())):
		solve()
	return
main()


t = int(input())
for _ in range(t):
	(q, d) = map(int, input().split())
	arrn = list(map(int, input().split()))
	for n in arrn:
		ld = n % 10
		ch = 0
		for i in range(1, 11):
			if d * i % 10 == ld and d * i <= n:
				ch = 1
				print('YES')
				break
		if ch == 0:
			if n >= d * 10:
				ch = 1
				print('YES')
			else:
				print('NO')


t = int(input())
while t > 0:
	t -= 1
	(q, d) = map(int, input().split(' '))
	l1 = [int(i) for i in input().split(' ')]
	for i in l1:
		if i >= d * 10:
			print('YES')
		elif d == 1:
			print('YES')
		elif i % d == 0:
			print('YES')
		elif i == d:
			print('YES')
		elif i < d:
			print('NO')
		else:
			flag = 0
			while i > d:
				ff = i % 10
				if ff == d:
					print('YES')
					flag = 1
					break
				i -= d
			if flag == 0:
				print('NO')


import sys
import bisect as bi
import collections as cc
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, d) = I()
	ar = I()
	for n in ar:
		if n >= 10 * d:
			print('YES')
		else:
			if str(d) in str(n):
				print('YES')
				continue
			tf = 0
			for j in range(d, n + 1, d):
				if str(d) in str(n - j):
					tf = 1
					break
			if tf:
				print('YES')
			else:
				print('NO')


def fn1(i, dream, dd):
	if str(dd) in str(i) or dd == 1:
		print('YES')
	else:
		x = i % dd
		if i >= dream[dd - 1][x]:
			print('YES')
		else:
			print('NO')
t = int(input())
for tc in range(t):
	(mm, dd) = map(int, input().split())
	lis = list(map(int, input().split()))
	dream = [[1], [2, 21], [3, 13, 23], [4, 41, 14, 43], [5, 51, 52, 53, 54], [6, 61, 26, 63, 16, 65], [7, 57, 37, 17, 67, 47, 27], [8, 81, 18, 83, 28, 85, 38, 87], [9, 19, 29, 39, 49, 59, 69, 79, 89]]
	for i in lis:
		fn1(i, dream, dd)


t = int(input())
for i in range(t):
	(q, d) = map(int, input().split())
	Q = list(map(int, input().split()))
	resultArr = [True] + [False] * (d * 10)
	for j in range(d * 10):
		if j < 10:
			resultArr[j] = j % d == 0
		else:
			for k in range(j // 10 + 1):
				if j - k * 10 - d > -1:
					resultArr[j] |= resultArr[j - k * 10 - d]
	for a in Q:
		if a < d * 10:
			print('YES' if resultArr[a] else 'NO')
		else:
			print('YES')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	str_d = str(d)
	li = list(map(int, input().split()))
	for i in range(n):
		new_val = li[i]
		while str_d not in str(new_val):
			new_val -= d
		if new_val > 0 and str_d in str(new_val):
			print('YES')
		else:
			print('NO')


import math
t = int(input())

def check(a, b):
	while a > 0:
		if a % 10 == b:
			return True
		a -= b
	return False
while t > 0:
	t -= 1
	stack1 = []
	(q, d) = map(int, input().split())
	stack = [int(x) for x in input().split()]
	dd = d * 10
	for i in stack:
		if i >= dd:
			print('YES')
		elif check(i, d):
			print('YES')
		else:
			print('NO')


def check(n, d):
	flag = 0
	if n >= 10 * d:
		flag = 1
	else:
		for i in range(1, 10):
			if (n - i * d) % 10 == 0 and n - i * d >= 0:
				flag = 1
	if flag == 1:
		return True
	elif flag == 0:
		return False
for _ in range(int(input())):
	(q, d) = map(int, input().split())
	ls = list(map(int, input().split()))
	for i in ls:
		if check(i, d) == True:
			print('YES')
		else:
			print('NO')


ans = []
for _ in range(int(input())):
	(q, d) = map(int, input().split())
	li = [int(i) for i in input().split()]
	for i in range(q):
		if li[i] >= d * 10:
			ans.append('YES')
		else:
			k = li[i]
			while k > 0:
				if k % d == 0:
					ans.append('YES')
					break
				k -= 10
			else:
				ans.append('NO')
print('\n'.join(ans))


t = int(input())
for i in range(t):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	lst1 = []
	lst2 = []
	for k in range(1, 11):
		if k * d % 10 in lst1:
			continue
		else:
			lst1.append(k * d % 10)
			lst2.append(k * d)
	for l in range(0, 10):
		if (10 * d + l) % 10 not in lst1:
			lst1.append((10 * d + l) % 10)
			lst2.append(10 * d + l)
	for j in range(len(a)):
		answer = 'NO'
		if a[j] % 10 in lst1:
			c = lst1.index(a[j] % 10)
			d = lst2[c]
			if a[j] >= d:
				answer = 'YES'
		print(answer)


def good(n, d):
	for i in str(n):
		if i == str(d):
			return True
	return False
t = int(input())
while t > 0:
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		if i % d == 0 or good(i, d):
			print('YES')
		else:
			f = False
			while i > d:
				i -= d
				if good(i, d):
					f = True
					break
			if f:
				print('YES')
			else:
				print('NO')
	t = t - 1


for _ in range(int(input())):
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))
	for num in a:
		if num > 10 * d:
			print('YES')
			continue
		while str(d) not in str(num):
			num -= d
		if num >= 0:
			print('YES')
		else:
			print('NO')


import math
import sys
from heapq import heappush, heappop
from collections import Counter, defaultdict, deque
input = lambda : sys.stdin.readline().strip()
c = lambda x: 10 ** 9 if x == '?' else int(x)

class node:

	def __init__(self, x, y):
		self.a = [x, y]

	def __lt__(self, b):
		return b.a[0] < self.a[0]

	def __repr__(self):
		return str(self.a[0]) + ' ' + str(self.a[1])

def main():
	for _ in range(int(input())):
		(n, d) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		for j in range(n):
			f = False
			for i in range(11):
				if a[j] % d == 0 or str(d) in str(a[j]):
					f = True
				if a[j] - d - i * 10 >= 0 and ((a[j] - d - i * 10) % d == 0 or str(d) in str(a[j] - d - i * 10)):
					f = True
				if f:
					break
			if f:
				print('YES')
			else:
				print('NO')
main()


Y = 'YES'
N = 'NO'
N = 'NO'
mem = {}
for i in range(3, 10):
	mem[i] = set()
	for j in range(i, i * 10):
		if j == i or j // 10 == i or j % 10 == i or (j - i in mem[i]):
			mem[i].add(j)

def test(x, n):
	if n == 1:
		return Y
	if n == 2:
		if x >= 20 or x % 2 == 0:
			return Y
		return N
	if x % n == 0 or x >= n * 10:
		return Y
	if x in mem[n]:
		return Y
	return N
t = int(input().strip())
for i in range(t):
	(q, d) = tuple(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	for j in range(q):
		print(test(a[j], d))


t = int(input())
for _ in range(t):
	qd = input().split(' ')
	q = int(qd[0])
	d = int(qd[1])
	a_vec = input().split(' ')
	a_vec = [int(a) for a in a_vec]
	MAX_DIGIT = 100
	dp = [0 for _ in range(MAX_DIGIT)]
	dp[0] = 1
	dp[d] = 1
	for i in range(1, MAX_DIGIT):
		for j in range(0, 10):
			if i >= j * 10 + d:
				dp[i] = dp[i] | dp[i - (j * 10 + d)]
	for a in a_vec:
		if a > 10 * d:
			print('YES')
		elif dp[a] == 1:
			print('YES')
		else:
			print('NO')


import sys
dd = {}
dd[2] = [0, 21]
dd[3] = [0, 13, 23]
dd[4] = [0, 41, 14, 43]
dd[5] = [0, 51, 52, 53, 54]
dd[6] = [0, 61, 26, 63, 16, 65]
dd[7] = [0, 57, 37, 17, 67, 47, 27]
dd[8] = [0, 81, 18, 83, 28, 85, 38, 87]
dd[9] = [0, 19, 29, 39, 49, 59, 69, 79, 89]
T = int(sys.stdin.readline().strip())
while T > 0:
	T -= 1
	(n, d) = sys.stdin.readline().strip().split(' ')
	b = sys.stdin.readline().strip()
	b = b.split(' ')
	for one in b:
		if d == '1':
			print('YES')
			continue
		if d in one:
			print('YES')
			continue
		(x, y) = (int(one), int(d))
		if x > dd[y][x % y]:
			print('YES')
		else:
			print('NO')


def Solve():
	for t in range(int(input())):
		(q, d) = map(int, input().split())
		a = list(map(int, input().split()))
		for i in a:
			while 0 < i < 10 * d and i % d != 0:
				i -= 10
			if i < d:
				print('NO')
			else:
				print('YES')
Solve()


n = int(input())

def check(n, d):
	if str(d) in str(n):
		return True
	elif n < d:
		return False
	else:
		return check(n - d, d)
for _ in range(n):
	(q, d) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	for i in l:
		if str(d) in str(i):
			print('YES')
		else:
			x = check(i, d)
			if x == True:
				print('YES')
			else:
				print('NO')


t = int(input())

def run_case(test):
	(n, d) = [int(x) for x in input().split()]
	lst = [int(x) for x in input().split()]
	for num in lst:
		if num >= 10 * d:
			print('YES')
			continue
		else:
			while num > 0:
				if num % d == 0:
					print('YES')
					break
				num -= 10
			if num <= 0:
				print('NO')
for test in range(t):
	run_case(test)


T = int(input())
for _ in range(T):
	(q, d) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	j = 0
	while j < q:
		s = str(l[j])
		if str(d) in s:
			print('YES')
			j += 1
			continue
		if d == 1:
			print('YES')
			j += 1
			continue
		elem = l[j]
		cnt = len(list(str(elem)))
		if cnt > 2 or (cnt == 2 and elem >= 10 * d):
			print('YES')
			j += 1
			continue
		f = 0
		while True:
			if elem <= 0 or f == 1:
				break
			x = elem % 10
			y = elem // 10
			if y != d and x != d:
				elem -= d
				continue
			f = 1
			break
		if f == 0:
			print('NO')
		else:
			print('YES')
		j += 1


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = [0]
	for i in range(m, 10 * m):
		if str(m) in str(i) and i % m != 0:
			l1.append(i)
	l2 = []
	for i in range(1, 10 * m):
		for j in range(len(l1)):
			if i > l1[j] and abs(l1[j] - i) % m == 0:
				l2.append(i)
	l2 = l2 + l1
	for i in range(n):
		if l[i] in l2 or l[i] >= 10 * m:
			print('YES')
		else:
			print('NO')


import sys
for _ in range(int(input())):
	(q, d) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		m_flag = 0
		if d > i:
			print('NO')
			mflag = 1
		elif i >= 10 * d:
			print('YES')
			m_flag = 1
		else:
			flag = 1
			while i > 0:
				if i % d == 0:
					print('YES')
					m_flag = 1
					break
				elif str(d) in str(i):
					print('YES')
					m_flag = 1
					break
				elif i < d:
					print('NO')
					m_flag = 1
					break
				else:
					p = d
					a = 0
					while i % 10 != p % 10 and a < 11:
						p += d
						a += 1
					if p > i:
						m_flag = 0
						break
					else:
						print('YES')
						m_flag = 1
						break
			if m_flag == 0:
				print('NO')


t = int(input())
while t != 0:
	(q, d) = map(int, input().split())
	a = list(map(int, input().split()))[:q]
	ans = []
	for x in a:
		yes = 0
		if x >= d * 10:
			yes = 1
		elif yes == 0:
			net = 0
			while net <= x:
				net += d
				if (x - net) % 10 == 0:
					yes = 1
					break
		if yes == 1:
			ans.append('YES')
		else:
			ans.append('NO')
	for i in ans:
		print(i)
	t -= 1