#include<iostream>
using namespace std;

int main(){
int a[10][90]={0};
int t;
cin>>t;
while(t--){
    int x,b;
    cin>>x>>b;
    for(int i=0;i<x;i++){
        int z;cin>>z;
        if(z>=(10*b)){cout<<"YES"<<endl;}else if(z%b==0){cout<<"YES"<<endl;}else if(a[b][z]){cout<<"YES"<<endl;}else{
                       int temp=z,k=0;
                       while(temp>0){
                        if(temp%10==b){k=1;a[b][temp]++;break;}
                        if(temp%b==0){k=1;a[b][temp]++;break;}
                        if(a[b][temp]){k++;break;}
                        temp-=b;
                       }
                       if(k>0){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
        }
    }
}
}