#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int q, d;
        cin >> q >> d;
        for(int i {}; i < q; i++){
           int x;
           cin >> x;
           int n = x;
           int flag = 0;
           if(n % d == 0)
             flag = 1;
           else if(n >= 10*d)
             flag = 1;  
           else{
               while(n > 0 ){
               n-=d;
               if(n % 10 == 0){
                   flag = 1;
                   break;
               }
             }

           }
           if(flag == 1)
             cout << "YES" << endl;
             else
             cout << "NO" << endl;
             
        }
    }

    return 0;
}