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

#define endl '\n'

using namespace std;

const int MAXN = 1e5 + 3;
const int BITS_SIZE = 63;

int64_t nums[MAXN];

void find_bits(int64_t num, vector<int>& bits)
{
    int pos = 0;
    while (num > 0)
    {
        bits[pos++] = (num % 2);
        num /= 2;
    }

    for (int i = pos ; i < BITS_SIZE; ++i)
    {
        bits[i] = 0;
    }
}

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

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

    vector<int> target_bits(BITS_SIZE, 0);
    find_bits(k, target_bits);

    vector<int> current_bits(BITS_SIZE, 0);

    string operations = "";
    for (int i = n - 1; i > 0; --i)
    {
        find_bits(nums[i], current_bits);

        bool is_and_operation_required = false;
        bool is_or_operation_required = false;

        /*cout << "target:  ";
        for (int i = 0; i < 6; ++i)
        {
            cout << target_bits[i];
        }
        cout << "\ncurrent: ";
        for (int i = 0; i < 6; ++i)
        {
            cout << current_bits[i];
        }
        cout << "\n\n";*/

        for (int i = 0; i < BITS_SIZE; ++i)
        {
            if (target_bits[i] == 0 and current_bits[i] == 1)
            {
                is_and_operation_required = true;
            }
            else if (target_bits[i] == 1 and current_bits[i] == 0)
            {
                is_or_operation_required = true;
            }
        }

        if (is_and_operation_required and is_or_operation_required)
        {
            cout << "NO\n";
            return;
        }

        if (!is_and_operation_required and !is_or_operation_required)
        {
            is_or_operation_required = true;
        }

        if (is_and_operation_required)
        {
            operations += "&";
        }
        else
        {
            operations += "|";
        }

        for (int i = 0; i < BITS_SIZE; ++i)
        {
            if (target_bits[i] == 2)
            {
                continue;
            }

            if (is_and_operation_required)
            {
                if (target_bits[i] == 0 and current_bits[i] == 0)
                {
                    target_bits[i] = 2;
                }
            }
            else
            {
                if (target_bits[i] == 1 and current_bits[i] == 1)
                {
                    target_bits[i] = 2;
                }
            }
        }
    }

    bool are_bits_ok = true;
    find_bits(nums[0], current_bits);

    for (int i = 0; i < BITS_SIZE; ++i)
    {
        if (target_bits[i] != 2 and target_bits[i] != current_bits[i])
        {
            are_bits_ok = false;
            break;
        }
    }

    if (are_bits_ok)
    {
        reverse(operations.begin(), operations.end());
        cout << "YES\n" << operations << endl;
    }
    else
    {
        cout << "NO\n";
    }
}

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

    int tests;
    cin >> tests;

    for (int test = 0; test < tests; ++test)
    {
        // cout << "Test " << test << ":\n\n";
        solve();
    }

    return 0;
}
