#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll t;
	cin>>t;
	while(t--){
		ll n,d,x,maxa=-1,y,z,flag=0;
cin>>n>>d;		
		int a[n];
		for(int i=0;i<n;i++)
		  cin>>a[i];
		  
		  if(d==1)
		  {
		for(int i=0;i<n;i++)
		cout<<"YES"<<endl;
		continue;
		  }
		  if(d==2)
		  {
		    for(int i=0;i<n;i++)
		   {
		       if(a[i]%2==1 && a[i]<20)
		       cout<<"NO"<<endl;
		       else
		       cout<<"YES"<<endl;
		   }  
		   continue;
		  }
		  if(d==5){
		for(int i=0;i<n;i++)
		{   
		    if(a[i]%5 !=0 && a[i]<50)
		    cout<<"NO"<<endl;
		    else
		    cout<<"YES"<<endl;
		    
		}
		continue;
		  }
		  map<ll,ll>mp;
		  mp.clear();
		  if(d%2==0)
	{
	  for(int i=1;i<=5;i++)
     {
         x=d*i;
       x=x%10;
       mp[x]=i;	
	}
	}
	 else
	{
	  for(int i=1;i<=10;i++)
     {
         x=d*i;
       x=x%10;
       mp[x]=i;	
	}
	}	 
	for(int i=0;i<n;i++)
		  {
		      if(a[i]<d*10){
		      x=a[i]%10;
		      if(d%2==0 && a[i]%2==1)
		      {
		          cout<<"NO"<<endl;
		      continue;
		      }
		      if(d*mp[x]>a[i])
		      cout<<"NO"<<endl;
		      else
		      cout<<"YES"<<endl;
		      }
		      else
		      cout<<"YES"<<endl;
		  }
		  
	    
	}
    return 0;
}