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

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

void solve2() {
    cin >> n >> k;
    for(ll i = 0; i < n; i ++) {
        cin >> arr[i];
    }

    for(ll mask = 0; mask < (1 << n); mask ++) {
        ll now = arr[0];
        for(ll i = 0; i < n - 1; i ++) {
            if(mask & (1 << i)) {
                now |= arr[i + 1];
            } else {
                now &= arr[i + 1];
            }
        }
        if(now == k) {
            cout << "YES" << endl;
            for(ll i = 0; i < n - 1; i ++) {
                if(mask & (1 << i)) {
                    cout << "|";
                } else {
                    cout << "&";
                }
            }
            cout << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

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

    for(ll i = 0; i < n - 1; i ++) {
        for(ll 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;
        ll now = k;
        ll 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);

    ll t;
    cin >> t;
    while(t --) {
        solve2();
    }

    return 0;
}
