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

#define fastio ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
const int N = 2e5 + 10;

int cnt[105];
bool dp[15][105];

void init(){
    for(int i = 1;i <= 9;i++){
        dp[i][0] = 1;
        for(int w = i ; w <= i * 10 ; w += 10){
            for(int j = w; j <= i * 10;j ++)
                dp[i][j] += dp[i][j - w];
        }
    }
}

void solve(){
    int q , d;
    init();
    cin >> q >> d;
    while(q--){
        int n;
        cin >> n;
        if(n >= 10 * d){
            puts("YES");
            continue;
        }
        if(dp[d][n])
            puts("YES");
        else
            puts("NO");
    }
}

int main(){
    int t;
    cin >> t;
    while(t--)
        solve();
    return 0;
}