#include<iostream>
using namespace std;

long long broiTestve;

long long broiChisla;
long long koeDaPoluchim;

long long chisla[100010];

bool taziKombinaciq(long long kombinaciq){
    int chi = chisla[0];

    for(int i = 1; i < broiChisla; i++){
        if(kombinaciq & 1 == 1){
            chi = chi & chisla[i];
        }else{
            chi = chi | chisla[i];
        }
        kombinaciq >>= 1;
    }

    if(chi == koeDaPoluchim){
        return true;
    }else{
        return false;
    }
}

int main(){

    cin>>broiTestve;

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

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

        long long doKadeVartim = 1 << (broiChisla - 1);

        bool stavaLi = false;
        long long priKoe = -1;

        for(long long i = 0; i < doKadeVartim; i++){
            if(taziKombinaciq(i) == true){
                stavaLi = true;
                priKoe = i;
                break;
            }
        }

        if(stavaLi == true){
            cout<<"YES"<<endl;
            for(long long i = 0; i < broiChisla - 1; i++){
                if(priKoe & 1 == 1){
                    cout<<"&";
                }else{
                    cout<<"|";
                }
                priKoe >>= 1;
            }
            cout<<endl;
        }else{
            cout<<"NO"<<endl;
        }

    }

    return 0;
}
