//ॐ
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define M 998244353
#define fr(i,n) for(int i=0;i<n;i++)
#define M2 1000000007
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define f first
#define s second
#define F(i,a,b) for(i=a;i<b;i++)
#define nl   "\n"
#define sp   " " 
#define all(c) (c).begin(),(c).end()
typedef long double ld;
typedef long long   ll;
typedef vector<ll>  vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
#define rev(i,b,a) for(int i=b;i>=a;i--)
#define iota  cout<<-1<<nl
#define cty  cout<<"YES"<<nl
#define ctn   cout<<"NO"<<nl
#define lmax  LLONG_MAX
#define lmin  LLONG_MIN
#define csp(x) cout<<(x)<<" "
#define c1(x) cout<<(x)<<nl
#define c2(x,y) cout<<(x)<<" "<<(y)<<nl
#define c3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<nl
#define c4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<nl
#define c5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<nl
#define c6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<nl
#define sz(v) (v).size()
const double pi=3.14159265358979323846264338327950288419716939937510582097494459230;
#define CASES  ll t;cin>>t;while(t--)
int main()
{
   fast;
   #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
      freopen("error.txt","w",stderr);
         freopen("output.txt","w",stdout);
   #endif
   CASES{
      ll q,d,i,x,y,z,j;
      cin>>q>>d;
      ll a[11],b[11],c[11];
      memset(c,-1,sizeof(c));
      for(i=1;i<=10;i++)
      {
         a[i] = (d*i)%10;
         ll z = (d*i)/10;
         b[i]=z;
         if(c[a[i]]==-1)
            c[a[i]]=z;
         //cout<<b[i]<<" "<<a[i]<<"\n";
      }
      
      while(q--)
      {
         cin>>x;
         if(x>=10*d)
         {
            cout<<"YES\n";
            continue;
         }
         z=x%10;
         if(c[z]==-1)
         {
            cout<<"NO\n";
            continue;
         }
         y=x/10;
         j=(x-z)/10;
         //cout<<z<<" "<<j<<"\n";
         if(c[z]<=y)
         cout<<"YES\n";
         else
            cout<<"NO\n";

      }
   }
   return 0;
}

   
