#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+7;
int a[maxn];
bool dfs(int x,int d)
{
	for(int i=0;i<=9;++i){
		if(i*10+d > x) break;
		else if(i*10+d == x) return true;
		else{
			if(dfs(x-(i*10+d),d)) return true;
		}
	}
	return false;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		int q,d;
		cin>>q>>d;
		for(int i=1;i<=q;++i) cin>>a[i];
		for(int i=1;i<=q;++i){
			int x=a[i];
			if(x >= 10*d) cout<<"YES" << endl;
			else
			{
				if(dfs(x,d)){
					cout << "YES" << endl;
				}
				else{
					cout << "NO"<< endl;
				}
			}
		}
		
	}
	return 0;
}