#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

bool isvalid(int temp,int d)
{
    while(temp>0)
    {
        if(temp%10==d) return true;
        temp = temp/10;
    }
    return false;
}


void solve(){
int q;
int d;
cin>>q>>d;
int temp;
for(int i=0;i<q;i++){
    cin>>temp;
    bool ans = false;
    while(temp>=d){
        if(isvalid(temp,d)) {ans=true;break;}
        temp-=d;
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
}

signed main()
{   fio;
    int t;
    cin>>t;
    while(t--){
        solve();
    }

    return 0;
}
