// Subtasks:
// 1: AC
// 2: AC
// 3: AC
// 5: AC
// _: TLE/WA

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

typedef long long ll;

using namespace std;

ll s[222222];

int main() {
    int t;
    cin>>t;
    for (int tt = 0; tt < t; tt++) {
        int n, k;
        cin>>n>>k;
        int cnt[n];
        int v[n];
        vector<int> p;
        for (int i = 1; i <= k; i++) cnt[i] = 0, s[i] = 0;
        for (int i = 0; i < n; i++) {
            int x;
            cin>>x;
            cnt[x]++;
        }
        int j = 0;
        for (int i = 1; i <= k; i++) {
            while (cnt[i] != 0 && cnt[i] != 1 && cnt[i] != 3) {
                cnt[i] -= 2;
                n -= 2;
                p.push_back(i);
            }
            if (cnt[i] == 1) {
                v[j++] = i;
            } else if (cnt[i] == 3) {
                v[j++] = i;
                v[j++] = i;
                v[j++] = i;
            }
        }

        random_shuffle(v, v + n);
        for (int i = 0; i < n; i++) {
            s[v[i]] += 2 * i + 1 - n;
        }
        ll tot = 0;
        for (int i = 1; i <= k; i++) {
            tot += s[i] * s[i];
        }
        for (int it = 0; tot > 0 && it < 20000000 / t; it++) {
            int i, j;
            i = rand() % n;
            j = rand() % n;
            if (v[i] == v[j]) continue;
            ll cur = s[v[i]] * s[v[i]] + s[v[j]] * s[v[j]];
            s[v[i]] -= 2 * i + 1 - n;
            s[v[j]] -= 2 * j + 1 - n;
            swap(v[i], v[j]);
            s[v[i]] += 2 * i + 1 - n;
            s[v[j]] += 2 * j + 1 - n;
            ll nxt = s[v[i]] * s[v[i]] + s[v[j]] * s[v[j]];
            if (nxt <= cur || rand() % (nxt - cur) == 0) {
                tot -= cur - nxt;
            } else {
                s[v[i]] -= 2 * i + 1 - n;
                s[v[j]] -= 2 * j + 1 - n;
                swap(v[i], v[j]);
                s[v[i]] += 2 * i + 1 - n;
                s[v[j]] += 2 * j + 1 - n;
            }
        }
        if (tot == 0) {
            cout<<"YES"<<endl;
            for (int i : p) cout<<i<<" ";
            for (int i = 0; i < n; i++) {
                cout<<v[i]<<" ";
            }
            reverse(p.begin(), p.end());
            for (int i : p) cout<<i<<" ";
            cout<<endl;
        } else {
            cout<<"NO"<<endl;
        }
    }
}