#include <iostream>
#include <vector>
#define endl "\n"
#define ll long long
using namespace std;

const ll maxn=1e5+1;
ll t,n,k,a[maxn];
vector<char> ans;

bool rek(ll ind, ll curr){
    if(ind==n){
        if(curr==k){
            return true;
        }
        return false;
    }
    if(curr==-1){
        if(rek(2,a[ind]&a[ind+1])){
            ans.push_back('&');
            return true;
        }
        if(rek(2,a[ind]|a[ind+1])){
            ans.push_back('|');
            return true;
        }
        return false;
    }
    if(rek(ind+1,curr&a[ind])){
        ans.push_back('&');
        return true;
    }
    if(rek(ind+1,curr|a[ind])){
        ans.push_back('|');
        return true;
    }
    return false;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
    cin >> t;
    while(t>0){
        cin >> n >> k;
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        if(rek(0,-1)){
            cout << "YES" << endl;
            for(int i=ans.size()-1;i>=0;i--){
                cout << ans[i];
            }
            cout << endl;
            ans.clear();
        }else{
            cout << "NO" << endl;
        }
        t--;
    }


}