#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;
}

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, "");

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

    }

    return 0;
}
