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

const int MAXN = 1000000;

int n;
long long k;
int s[MAXN + 5];
long long a[MAXN + 5];

void solve1()
{
    for (int mask = 0; mask < (1ll << (n - 1)); ++ mask)
    {
        long long num = a[1];
        for (int i = 2; i <= n; ++ i)
        {
            if (mask & (1ll << (i - 2))) num &= a[i];
            else num |= a[i];
        }
        if (num == k)
        {
            cout << "YES" << endl;
            for (int i = 2; i <= n; ++ i)
            {
                if (mask & (1ll << (i - 2))) cout << "&";
                else cout << "|";
            }
            cout << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

bool solve2()
{
    long long b = (1ll << 61) - 1;
    for (int i = n; i > 1; -- i)
    {
        if (((a[i] & b) | k) != k)
        {
            b &= a[i];
            s[i] = 1;
        }
        else
        {
            s[i] = 0;
            b |= a[i];
        }
    }

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

    if (num == k)
    {
        cout << "YES" << endl;
        for (int i = 2; i <= n; ++ i)
        {
            if (s[i]) cout << "&";
            else cout << "|";
        }
        cout << endl;
        return true;
    }
    return false;
}

long long Or[MAXN + 5], And[MAXN + 5];

bool solve3()
{
    Or[1] = a[1];
    for (int i = 2; i <= n; ++ i)
    {
        Or[i] = (Or[i - 1] | a[i]);
    }

    And[n] = a[n];
    for (int i = n - 1; i >= 1; -- i)
    {
        And[i] = (And[i + 1] & a[i]);
    }

    if (Or[n] == k)
    {
        cout << "YES" << endl;
        for (int i = 1; i < n; ++ i)
        {
            cout << "|";
        }
        cout << endl;
        return true;
    }

    if (And[1] == k)
    {
        cout << "YES" << endl;
        for (int i = 1; i < n; ++ i)
        {
            cout << "&";
        }
        cout << endl;
        return true;
    }

    for (int i = 1; i <= n; ++ i)
    {
        if ((Or[i - 1] & And[i]) == k)
        {
            cout << "YES" << endl;
            for (int j = 2; j < i; ++ j)
            {
                cout << "|";
            }
            for (int j = i; j <= n; ++ j)
            {
                cout << "&";
            }
            cout << endl;
            return true;
        }
    }
    return false;
}

bool solve4()
{
    long long b = (1ll << 61) - 1;
    for (int i = n; i > 1; -- i)
    {
        if (((a[i] & b) | k) != k)
        {
            b &= a[i];
            s[i] = 1;
        }
        else
        {
            s[i] = 0;
            ///b |= a[i];
        }
    }

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

    if (num == k)
    {
        cout << "YES" << endl;
        for (int i = 2; i <= n; ++ i)
        {
            if (s[i]) cout << "&";
            else cout << "|";
        }
        cout << endl;
        return true;
    }
    return false;
}

void solve()
{
    cin >> n >> k;

    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
    }

    if (n <= 20)
    {
        solve1();
        return;
    }

    if (solve2()) return;

    if (solve3()) return;

    if (solve4()) return;

    for (int i = 1; i <= n; ++ i)
    {
        s[i] = 0;
    }

    long long b = (1ll << 61) - 1;
    for (int i = n; i > 1; -- i)
    {
        if (((a[i] & b) | k) != k)
        {
            b &= a[i];
            s[i] = 1;
        }
        else
        {
            s[i] = 0;
            b = b - (b & a[i]);
        }
    }

    long long num = a[1];
    for (int i = 2; i <= n; ++ i)
    {
        if (s[i]) num &= a[i];
        else num |= a[i];
    }
    if (num == k)
    {
        cout << "YES" << endl;
        for (int i = 2; i <= n; ++ i)
        {
            if (s[i]) 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;
}
