#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll Size=1e3+1;
ll a[Size];
string dp[Size][2025];

void solve(){
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll m=1;
    for(ll i=0;i<n-1;i++){
        m*=2;
    }
    for(ll i=0;i<m;i++){
        string res="";
        ll ans=a[0];
        for(ll j=1;j<n;j++){
            if(i&(1<<j-1)){
                ans=ans&a[j];
                res+="&";
            }else{
                ans=ans|a[j];
                res+="|";
            }
        }
        if(ans==k){
            cout<<"YES"<<endl<<res<<endl;
            return;
        }
    }
    cout<<"NO"<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
