#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll q,d;
        cin>>q>>d;
        ll a[q];
        for(ll i=0;i<q;i++)
            cin>>a[i];
        int flag=0;
        for(ll i=0;i<q;i++)
        {
           ll div=a[i]/d;
           ll rem=a[i]%d;
           if(div>=10)
            cout<<"YES\n";
       else if(rem==0) cout<<"YES\n";
        else{
           for(ll j=1;j<=div;j++)
           {
               rem+=d;
               if(rem%10==d)
                flag=1;
           }
           if(flag)
           {
            cout<<"YES"<<'\n';
            flag=0;
           }
           else
            cout<<"NO"<<'\n';
        }

        }
    }
}
