#include <iostream>
#define endl '\n'
using namespace std;

const int MAXN = 100000;

int no[64];
long long a[MAXN + 5];

void solve()
{
    int n;
    long long k;
    cin >> n >> k;
    
    for (int i = 0; i < 61; ++ i)
    {
        no[i] = 0;
    }

    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        for (int j = 0; j < 61; ++ j)
        {
            if (!(a[i] & (1ll << j))) no[j] = i;
        }
    }

    int p = n + 1;
    for (int i = 0; i < 61; ++ i)
    {
        if (!(k & (1ll << i))) p = min(p, no[i] + 1);
    }

    long long num = a[1];
    for (int i = 2; i <= n; ++ i)
    {
        if (i < p) num |= a[i];
        else num &= a[i];
    }

    if (num == k)
    {
        cout << "YES" << endl;
        for (int i = 2; i <= n; ++ i)
        {
            if (i < p) cout << "|";
            else cout << "&";
        }
        cout << endl;
    }
    else cout << "NO" << endl;
}

int main()
{
    ios :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t;
    cin >> t;

    while (t--)
    {
        solve();
    }

    return 0;
}
