#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	long long int t;
	cin>>t;
	while(t--)
	{
	    long long int n,d;
	    cin>>n>>d;
	    long long int ar[n];
	    for(int i=0;i<n;i++)
	    cin>>ar[i];
	    for(int i=0;i<n;i++)
	    {
	        if(ar[i]>=d*10)
	        {
	            cout<<"YES"<<endl;
	        }
	        else
	        {
	            int flag=0;
	            for(long long int j=1;j<=10;j++)
	            {
	                if((d*j)%10==ar[i]%10)
	                {
	                    if(d*j==ar[i] || d*j+10<=ar[i])
	                    {
	                        flag=1;
	                        break;
	                    }
	                }
	            }
	            if(flag==0)
	            cout<<"NO"<<endl;
	            else
	            cout<<"YES"<<endl;
	        }
	    }
	}
	// your code goes here
	return 0;
}
