#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 3e3+5;
const int mod = 0x3f3f3f3f;
int n,d,q;

void solve(int n){
	if(n>=10*d){
		cout<<"YES"<<endl;
		return;
	}
	for(int i=1;i<=9;i++){
		if(n>=d*i&&(n-i*d)%10==0){
			cout<<"YES"<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		
		cin>>q>>d;
		for(int i=0;i<q;i++){
			cin>>n;
			solve(n);
		}
	} 
	
	return 0;
} 
