#include<bits/stdc++.h>
#define Case int t;scanf("%d",&t);while(t--)
using namespace std; 
typedef long long ll;
const int maxn=3e5+10;
ll a[maxn];
char s[maxn];
int cnt;
bool solve(ll n,ll d){
	while(n){
		ll t=n%10;
		if(d==n){
			return 1;
		}
		n=n/10;
	}
	return 0;
}
void run(){
	ll n,d;
	scanf("%lld%lld",&n,&d);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++){
		if(solve(a[i],d)){
			printf("YES\n");
			continue;
		}
		if(a[i]>=d*10){
			printf("YES\n");
			continue;
		}
		ll cnt=0;
		int flag=0;
		while(a[i]-cnt*10>0){
			if((a[i]-cnt*10)%d==0){
				flag=1;
				printf("YES\n");
				break;
			}
			cnt++;
		}
		if(!flag)printf("NO\n");
	}
}
int main(){
	Case
		run();
	return 0;
}