// Subtasks:
// 1: AC
// _: TLE/WA

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

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        if (n > 15) return 0;
        vector<int> colors(n);
        for (int i = 0; i < n; i++) cin >> colors[i];
        sort(colors.begin(), colors.end());
        int count = 0;
        do {
            count++;
            if (count > 2e7) {
                cout << "NO\n";
                return 0;
            }
            vector<int> color_count(k+1);
            vector<int> color_sum(k+1);
            for (int i = 0; i < n; i++) {
                color_count[colors[i]]++;
                color_sum[colors[i]] += (i + 1);
            }
            bool fail = false;
            for (int i = 1; i <= k; i++) {
                if ((2 * color_sum[i]) % color_count[i] != 0) fail = true;
                if ((2 * color_sum[i]) / color_count[i] != n + 1) fail = true;
            }
            if (!fail) {
                cout << "YES\n";
                for (int i = 0; i < n; i++) cout << colors[i] << " ";
                cout << "\n";
                goto done;
            }
        } while (next_permutation(colors.begin(), colors.end()));
        cout << "NO\n";
        done:;
    }
}
