#include <bits/stdc++.h>
 
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD  1000000007

int main()
{
	FAST;
	//mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());

	int T;
	cin >> T;
	
	vector<vector<int> > Map(10, vector<int>(90));
	int i, j, k;

	for(i = 1; i < 10; i++)
	{
		Map[i][0] = 1;
		
		for(j = 0; j < (10 * i); j++)
		{
			if(Map[i][j])
			{
				for(k = 0; k <= i; k++)
				{
					if(((k * 10) + i + j) < (10 * i))
					{
						Map[i][((k * 10) + i + j)] = 1;
					}
				}
			}
		}
	}
	
	for(i = 0; i < T; i++)
	{
		int Q, D;
		cin >> Q >> D;
		
		for(j = 0; j < Q; j++)
		{
			int A;
			cin >> A;
			
			if(A >= (10 * D))
			{
				cout << "YES" << endl;
			}
			else
			{
				cout << (Map[D][A] ? "YES" : "NO") << endl;
			}
		}
	}

	return 0;
}