#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+6;
int a[MAXN];
int n,k;
bool ready[MAXN];
bool needs_one[MAXN];
bool needs_zero[MAXN];
void solve()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    int current_block=0,last=-1;
    vector<int>blocks;
    vector<bool>neshta(n+1,0);
    for(int 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;
    }
    int val=(1<<31)-1;
    for(int 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(int i=1;i<neshta.size()-1;i++)
    {
        if(neshta[i]==1)cout<<"&";
        else cout<<"|";
    }
    cout<<endl;
}
int main()
{
    int t;cin>>t;
    while(t--)solve();
return 0;
}
