#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;cin >> t;
while(t--)
{
int n,p;cin >> n >> p;
//cout << n << " " << p << endl;
int arr[n];
// v stores divisors,v1 stores non divisors
vector< pair <int,int> > v,v1;
for(int i = 0;i<n;i++){
cin >> arr[i] ;
// cout << arr[i] << endl;
if(arr[i] != 1 && p%arr[i] == 0)
{
// cout << " uu" << endl;
v.push_back(make_pair(arr[i],i));
// cout << v[0].first << endl;
}
else if(arr[i] != 1 && p%arr[i] != 0){
v1.push_back(make_pair(arr[i],i));
//v2.push_back(arr[i]);
}
}
// cout << "JJ" << endl;
// cout << "dD" << v[0].first << endl;
sort(v.begin(),v.end());
// cout << v[0].first << endl;
vector<int> q(n,0);
//cout << " V size " << v.size() << endl;
//cout << v1[0].second << " v1[0]" << endl;
if(v1.size() >= 1)
{
cout << "YES ";
q[v1[0].second] = p/v1[0].first + 1;
for(int i = 0;i<q.size();i++){
cout << q[i] << " ";
}
cout << endl;
}
else if(v.size() >=2 )
{
int cp = 0;
int i = 0,j=0;
for(i = 0;i<v.size()-1;i++){
for(j=i+1;j<v.size();j++)
// cout << v[i].first << endl;
{
if(v[j].first % v[i].first != 0){
cp++;
break;
}
}
if(cp>=1)
break;
}
q[v[i].second] = (p/v[i].first) - 1;
q[v[j].second] = 1;
// cout << v[i].first <<" " << q[v[i].second] << endl;
//cout << v[j].first << " " << q[v[j].second] << endl;
// cout <<"ZZ" << endl;
if(cp == 0)
cout << "NO" << endl;
else{
cout << "YES " ;
for(int i = 0;i<q.size();i++){
cout << q[i] << " ";
}
cout << endl;
}
}
else{
//if(v.size() == 1)
cout << "NO" << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKICAgIGludCB0O2NpbiA+PiB0OwogCXdoaWxlKHQtLSkKCXsKCQlpbnQgbixwO2N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