#include<iostream>
using namespace std;

int broiTestve;

int broiChisla;
int koeDaPoluchim;

long long chisla[100010];

string resh;

bool daiReshenie(long long parvoChislo, long long indexVtoro, string doTuk){
    if(indexVtoro == broiChisla){
        if(parvoChislo == koeDaPoluchim){
            resh = doTuk;
            return true;
        }else{
            return false;
        }
    }

    bool tuka = (daiReshenie(parvoChislo | chisla[indexVtoro], indexVtoro + 1, doTuk + "|") ||
                 daiReshenie(parvoChislo & chisla[indexVtoro], indexVtoro + 1, doTuk + "&"));
    return tuka;
}

bool proveri(string posledov){
    //cout<<"proverqvame "<<posledov<<endl;

    long long naiOtprede = chisla[0];

    for(int i = 1; i < broiChisla; i++){
        //cout<<naiOtprede;
        if(posledov[i - 1] == '|'){
            naiOtprede = naiOtprede | chisla[i];
            //cout<<"|"<<chisla[i]<<" -> "<<naiOtprede<<endl;
        }else{
            naiOtprede = naiOtprede & chisla[i];
            //cout<<"&"<<chisla[i]<<" -> "<<naiOtprede<<endl;
        }
    }

    return naiOtprede == koeDaPoluchim;
}

bool nameriReshenie(int index, string doTuk){
    if(index == broiChisla - 1){
        if(proveri(doTuk) == true){
            resh = doTuk;
            return true;
        }else{
            return false;
        }
    }

    bool tuka = nameriReshenie(index + 1, doTuk + "|") | nameriReshenie(index + 1, doTuk + "&");

    return tuka;
}

int main(){

    cin>>broiTestve;

    for(int t = 0; t < broiTestve; t++){
        cin>>broiChisla>>koeDaPoluchim;

        for(int i = 0; i < broiChisla; i++){
            cin>>chisla[i];
        }

        //bool imaLi = daiReshenie(chisla[0], 1, "");
        bool imaLi = nameriReshenie(0, "");

        if(imaLi == true){
            cout<<"YES"<<endl;
            cout<<resh<<endl;
        }else{
            cout<<"NO"<<endl;
        }

    }

    return 0;
}
