#include "bits/stdc++.h"
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define endl '\n'
#define inf 1000000000000000007
#define int long long
#define fi first
#define sc second
#define pb push_back
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

const int mod = 1e9 + 7;
const int N = 1e6 + 7;
const int maxn = 1007;

int n, m, a[N];

void __solve(){	
			int q, d; cin >> q >> d;
			for(int i = 0; i < q; i++){
				int a; cin >> a;
				if(a >= 10 * d){
					cout << "YES" << endl;
					continue;
				}
				int ok = 0;
				for(int x = 0; x <= 10; x++){
					for(int y = 1; y <= 10; y++){
						if(10 * x + y * d == a){
							cout << "YES" << endl;
							ok = 1;
							break;
						}
					}
					if(ok) break;
				}

				if(!ok){
					cout << "NO" << endl;
				}
			}
}

int32_t main(){
io();
IOS;    
			int t = 1;
			cin >> t;
			for(int i = 1; i <= t; i++){
				// cout << "Case #" << i << ": ";
				__solve();
			}
			#ifndef ONLINE_JUDGE
		    	cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
		    #endif
		



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

	