#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
#include <bitset>
#include <climits>
#include <list>
#include <stack>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define f first
#define s second
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define F0R(i, x) FOR(i, 0, x)
#define FORd(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define F0Rd(i, x) FORd(i, 0, x)
const int MAX_N = 100001;
const ll MOD = 1000000007;
const ll INF = 1e18;

void solve(){
    int d, n; cin >> n >> d;
    F0R(i, n){
        int x, num; cin >> x;
        bool works = false;
        if(x >= 10*d) works = true;
        FOR(j, 1, 11) if(x%10 == d*j%10)
            if(x >= d*j) works = true;
        if(works) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return;
}

int main(int argc, const char * argv[]){
    int t; cin >> t; // t = 1;
    while(t--){
        solve();
    }
    return 0;
}
