#include<bits/stdc++.h>
 
#define ar array 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(v) int((v).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,a,b) for(int i = a; i < b; i++)
#define deb(x) cout << #x << "=" << x << endl
#define PI 3.1415926535897932384626
#define endl '\n'
 
using namespace std;
 
typedef long long ll; 
typedef long double ld; 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
 
const  int mxN = 1e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;


void solve() {
	int n, d;
	cin >> n  >> d;

	rep(i, 0, n) {
		int x;
		cin >> x;
		int var = x % d;
		
		if(d * 10 + var <= x) {
			cout << "YES" << endl;
			continue;
		}

		if(x >= 100) {
			cout << "YES" << endl;
			continue;
		}
		if(x < d) {
			cout << "NO" << endl;
			continue;
		}

		int cur = d;
		
		bool flag = false;
		while(cur <= x) {
			int temp = x - cur;
			if(temp % 10 == 0) {
				flag = true;
				break;
			}
			cur += d;
		}
		while(x) {
			int rem = x % 10;
			if(rem == d) flag = true;
			x /= 10;
		}
		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int t = 1;
cin >> t;
while(t--) {
solve();
}
}


