/*
 
Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.
 
- Tooru Oikawa.
 
*/

#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
#define ld long double
#define ll long long int
#define f first
#define s second
#define mk make_pair
#define pb push_back
#define vv vector<ll>
#define ve vector
#define pll pair<ll,ll>
#define pa pair
#define fr(i, a, b) for (ll i = a; i < b; ++i)
#define frn(i, a, b) for (ll i = a; i > b; --i)
#define MAX 100005
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000009
#define endl "\n"
#define inarr(arr,n); for(int i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(int i=0;i<n;i++) cout<<arr[i]<<' ';
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define sz(a) (int)((a).size())
#define deci fixed<<setprecision(9)
const ll inf = 9e18;
const ld pi = 2*acos(0.0);

ll arr[MAX];
void solve()
{
    ll q,d;
    cin>>q>>d;
    inarr(arr,q);
    if(d==1LL)
    {
       fr(i,0,q)cout<<"YES"<<endl; 
    }
    else if(d==2LL)
    {
        fr(i,0,q)
        {
            if(arr[i]%2==0LL)cout<<"YES"<<endl;
            else if(arr[i]>20)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    else if(d==3LL)
    {
        fr(i,0,q)
        {
            if(arr[i]%3==0)cout<<"YES"<<endl;
            else if(arr[i]%3==1LL && arr[i]>=13)cout<<"YES"<<endl;
            else if(arr[i]%3==2LL && arr[i]>=23)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    else if(d==4LL)
    {
        fr(i,0,q)
        {
            if(arr[i]%4==0)cout<<"YES"<<endl;
            else if(arr[i]%4==1LL && arr[i]>=41)cout<<"YES"<<endl;
            else if(arr[i]%4==2LL && arr[i]>=14)cout<<"YES"<<endl;
            else if(arr[i]%4==3LL && arr[i]>=43)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    else if(d==5LL)
    {
        fr(i,0,q)
        {
            if(arr[i]%5==0)cout<<"YES"<<endl;
            else if(arr[i]%5==1LL && arr[i]>=51)cout<<"YES"<<endl;
            else if(arr[i]%5==2LL && arr[i]>=52)cout<<"YES"<<endl;
            else if(arr[i]%5==3LL && arr[i]>=53)cout<<"YES"<<endl;
            else if(arr[i]%5==4LL && arr[i]>=54)cout<<"YES"<<endl; 
            else cout<<"NO"<<endl;
        }

    }
    else if(d==6LL)
    {
        fr(i,0,q)
        {
            if(arr[i]%6==0)cout<<"YES"<<endl;
            else if(arr[i]%6==1LL && arr[i]>=61)cout<<"YES"<<endl;
            else if(arr[i]%6==2LL && arr[i]>=26)cout<<"YES"<<endl;
            else if(arr[i]%6==3LL && arr[i]>=63)cout<<"YES"<<endl;
            else if(arr[i]%6==4LL && arr[i]>=16)cout<<"YES"<<endl; 
            else if(arr[i]%6==5LL && arr[i]>=65)cout<<"YES"<<endl; 
            else cout<<"NO"<<endl;
        }
    }
    else if(d==7LL)
    {

        fr(i,0,q)
        {
            if(arr[i]%7==0)cout<<"YES"<<endl;
            else if(arr[i]%7==1LL && arr[i]>=57)cout<<"YES"<<endl;
            else if(arr[i]%7==2LL && arr[i]>=37)cout<<"YES"<<endl;
            else if(arr[i]%7==3LL && arr[i]>=17)cout<<"YES"<<endl;
            else if(arr[i]%7==4LL && arr[i]>=67)cout<<"YES"<<endl; 
            else if(arr[i]%7==5LL && arr[i]>=47)cout<<"YES"<<endl; 
            else if(arr[i]%7==6LL && arr[i]>=27)cout<<"YES"<<endl; 
            else cout<<"NO"<<endl;
        }
    }
    else if(d==8LL)
    {

        fr(i,0,q)
        {
            if(arr[i]%8==0)cout<<"YES"<<endl;
            else if(arr[i]%8==1LL && arr[i]>=81)cout<<"YES"<<endl;
            else if(arr[i]%8==2LL && arr[i]>=18)cout<<"YES"<<endl;
            else if(arr[i]%8==3LL && arr[i]>=83)cout<<"YES"<<endl;
            else if(arr[i]%8==4LL && arr[i]>=28)cout<<"YES"<<endl; 
            else if(arr[i]%8==5LL && arr[i]>=85)cout<<"YES"<<endl; 
            else if(arr[i]%8==6LL && arr[i]>=38)cout<<"YES"<<endl; 
            else if(arr[i]%8==7LL && arr[i]>=87)cout<<"YES"<<endl; 
            else cout<<"NO"<<endl;
        }
    }
    else if(d==9LL)
    {

        fr(i,0,q)
        {
            if(arr[i]%9==0)cout<<"YES"<<endl;
            else if(arr[i]%9==1LL && arr[i]>=19)cout<<"YES"<<endl;
            else if(arr[i]%9==2LL && arr[i]>=29)cout<<"YES"<<endl;
            else if(arr[i]%9==3LL && arr[i]>=39)cout<<"YES"<<endl;
            else if(arr[i]%9==4LL && arr[i]>=49)cout<<"YES"<<endl; 
            else if(arr[i]%9==5LL && arr[i]>=59)cout<<"YES"<<endl; 
            else if(arr[i]%9==6LL && arr[i]>=69)cout<<"YES"<<endl; 
            else if(arr[i]%9==7LL && arr[i]>=79)cout<<"YES"<<endl; 
            else if(arr[i]%9==8LL && arr[i]>=89)cout<<"YES"<<endl; 
            else cout<<"NO"<<endl;
        }
    }
    return;
}






int main()
{
    IOS;
    ll tc=1;
    cin>>tc;
    while(tc--)
    {
        solve();
    }
}