#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int N = 1e6+10;
ll n,t,m,k,d;
int a[N],b[N];
void solve(){
    cin>>n>>d;
    for(int i = 1;i <= n;++i){
        cin>>a[i];
        int u = a[i]/d;
        int v = a[i]%d;
        if(!v||u >= 10){
            cout<<"YES"<<endl;
        }
        else {
            bool f = 0;
            for(int i = 1; i <= u &&i <= 9;++i){
                int now = i*d%10;
                if(now<d)now = d-now;
                else now = 10+d-now;
                if(now == v){
                    f = 1;
                    break;
                }

            }
            if(f)cout<<"YES"<<'\n';
            else cout<<"NO"<<'\n';

        }
    }
}

int main() {
   /* freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);*/

    cin>>t;
    while(t--){

       solve();


    }


   /* fclose(stdin);
    fclose(stdout);*/
    return 0;
}
