#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    while(n--){
        int q,d;
        cin >> q >> d;
        for(int i = 0; i < q; i ++){
            int numero;
            cin >> numero;
            if(numero >= 100){
                cout << "YES" << endl;
                continue;
            }else{
                int f;
                while(numero >= 0){
                    int aux = numero;
                    f = 0;
                    while(aux != 0){
                        int sorte = aux%10;
                        aux = aux/10;
                        if(sorte == d){
                            f = 1;
                            cout << "YES" << endl;
                            break;
                        }
                    }
                    if(f) break;
                    numero = numero-d;
                }if(f == 0){
                    cout << "NO" << endl;
                }
            }
        }
    }
    return 0;
}