#include<bits/stdc++.h>

using namespace std;

#define ll long long int
#define tc ll t;cin>>t;while(t--)
#define PI 2*acos(0)
#define mset(pq) memset(pq, 0, sizeof(pq));
#define pb push_back
#define sp " "

ll M=1e9+7;

int sum_digit(int x) { int sum=0; while(x>0){ sum+=x%10; x/=10; } return sum; }
int reverse_num(int n){ int tmp=n, ans=0, r; while(tmp>0){ r=tmp%10; ans=ans*10+r; tmp/=10; } return ans; }
ll factorial(ll n){ ll i, ans=1; for(i=n; i>1; i--){ans*=i;} return ans; }
ll gcd(ll num1, ll num2) { ll a,b,r; a=num1; b=num2; r=a%b; while(r>0){ a=b; b=r; r=a%b; } return b; }
ll lcm(ll num1, ll num2) { return (num1*num2)/gcd(num1, num2); }
bool prime(ll n) { if(n<2) return false; for(ll i=2;i<=sqrt(n);i++){ if(n%i==0)return false;} return true; }


void solve()
{
    ll n, d, i, j, flag, x, tmp;
    cin >> n >> d;
    ll cnt[11]={}, check[11]={};
    for(i=1; i<=10; i++)
    {
        ll tmp = d*i;
        if(cnt[tmp%10]==0)
        {
            cnt[tmp%10]=1;
            check[tmp%10]=tmp;
        }
    }

    while(n--)
    {
        cin >> x;

        j++;
        if(x<d)
        {
            cout << "NO\n";
        }
        else if(x>=d*10 || x%d==0 || x%10==d)
        {
            cout << "YES\n";
        }
        else
        {
            if(cnt[x%10]==1 && check[x%10]<=x)
                cout << "YES\n";
            else
                cout << "NO\n";
        }
    }

}

int main()
{
    tc
    solve();
    return 0;
}
