#include <bits/stdc++.h>
#define endl "\n"
#pragma GCC optimize("Ofast")
using namespace std;
const int mod = 1e9 + 7;

const int MAX_N = 3e3 + 40;
bool can[MAX_N][MAX_N];
pair<int, bool> hist[MAX_N][MAX_N];
int n, k, arr[MAX_N];

void solve() {
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    for(int i = 0; i < MAX_N; i ++) {
        for(int j = 0; j < MAX_N; j ++) {
            can[i][j] = false;
        }
    }
    can[0][arr[0]] = true;

    for(int i = 0; i < n - 1; i ++) {
        for(int val = 0; val < MAX_N; val ++) {
            if(!can[i][val]) { continue; }
            can[i + 1][val | arr[i + 1]] = true;
            hist[i + 1][val | arr[i + 1]] = {val, false};
            can[i + 1][val & arr[i + 1]] = true;
            hist[i + 1][val & arr[i + 1]] = {val, true};
        }
    }

    if(!can[n - 1][k]) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        int now = k;
        int pos = n - 1;
        string ret;
        while(pos != 0) {
            if(hist[pos][now].second) {
                ret += '&';
            } else {
                ret += '|';
            }
            now = hist[pos][now].first;
            pos --;
        }
        reverse(ret.begin(), ret.end());
        cout << ret << endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int t;
    cin >> t;
    while(t --) {
        solve();
    }

    return 0;
}
