#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(j,b,a) for(ll j=b;j>a;j--)
using namespace std;

int main()
{
    fio;
    ll tc,n,a,b,m,x,y,i,j,k,c=0;
    cin>>tc;
    while(tc--)
    {
        cin>>n>>m;
        f(i,0,n)
        {
            cin>>x;
            bool check=false;
            if(x>=m*10)
                check=true;
            if(!check)
            {
                while(x>=m)
                {
                    if(x%m==0)
                    {
                        check=true;
                        break;
                    }
                    x-=10;
                }
            }
            if(check)
                cout<<"YES\n";
            else
                cout<<"NO\n";
        }
    }
    return 0;
}

