#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXN=1e5+6;
ll a[MAXN];
ll n,k;
bool ready[MAXN];
bool needs_one[MAXN];
bool needs_zero[MAXN];
void solve()
{
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i];
    /*ll current_block=0,last=-1;
    vector<ll>blocks;
    vector<bool>neshta(n+1,0);
    for(ll i=1;i<=n;i++)
    {
        current_block|=a[i];
        if((current_block&k)==k)
        {
            blocks.push_back(current_block);
            current_block=0;last=i;
            neshta[i]=1;
        }
    }
    if(last!=n)
    {
        neshta[last]=0;
        blocks[blocks.size()-1]|=current_block;
    }
    ll val=(1<<31)-1;
    for(ll i=0;i<blocks.size();i++)
    {
        //cout<<blocks[i]<<" ";
        val&=blocks[i];
    }
    //cout<<endl;
    if(val==k)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
        return;
    }
    for(ll i=1;i<neshta.size()-1;i++)
    {
        if(neshta[i]==1)cout<<"&";
        else cout<<"|";
    }
    cout<<endl;*/
    for(ll mask=0;mask<(1<<(n-1));mask++)
    {
        ll cur=a[1];
        for(ll j=2;j<=n;j++)
        {
            if(mask&(1<<(j-2)))cur|=a[j];
            else cur&=a[j];
        }
        if(cur==k)
        {
            cout<<"YES\n";
            for(ll j=2;j<=n;j++)
            {
                if(mask&(1<<(j-2)))cout<<"|";
                else cout<<"&";
            }
            cout<<endl;
            return;
        }
    }
    cout<<"NO\n";

}
int main()
{
    ll t;cin>>t;
    while(t--)solve();
return 0;
}
