#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


int operation(int top1, int top2) {



    return 0;
}

string attempt(vector<int> a, int N, int K) {
    for (int i = 0; i < exp2(N-1); i++) {
        vector<int> a_copy = a;
        string op = "";
        for (int j = 1; a_copy.size() > 1; j *= 2) {
            int top1 = a_copy.back();
            a_copy.pop_back();
            int top2 = a_copy.back();
            a_copy.pop_back();
            if (!(i & j)) {
                a_copy.push_back(top1 & top2);
                op += "&";
                //cout << "&";
                //cout << i << "&" << j << "=" << (i & j) << ", ";
            } else {
                a_copy.push_back(top1 | top2);
                op += "|";
                //cout << "|";
                //cout << i << "&" << j << "=" << (i & j) << ", ";
            }
        }
        if(a_copy.back() == K) {
            //cout << "YES\n";
            //cout << op << "\n";
            return "YES\n" + op;
        }
        //cout << " left = " << a_copy.back() << "\n";
    }
    //cout << "NO\n";
    return "NO";
}

int main() {

    int T;
    string result = "";
    cin >> T;
    for (int i = 0; i < T; i++) {
        int N, K;
        cin >> N >> K;
        vector<int> a(N);
        for (int j = N-1; j >= 0; j--) {
            int an;
            cin >> an;
            a[j] = an;
        }

        result += attempt(a, N, K);
        if (i + 1 != T) {
            result += "\n";
        }
    }
    cout << result;

    return 0;
}
