#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    cin >> t;

    while(t--) {
        int n, m, x;
        cin >> n >> m >> x;
        vector<int> his(n), indices(n), sol(n);
        REP(i, n) {
            indices[i] = i;
            cin >> his[i];
        }
        sort(begin(indices), end(indices), [&his](const int i, const int j) {
            return his[i] < his[j];
        });

        vector<pair<int, int>> heap;
        REP(i, m) heap.emplace_back(0, i);
        auto comp = [](const pair<int, int> &lhs, const pair<int, int> &rhs) {
            return lhs.first > rhs.first;
        };

        REP(i, n) {
            int index = indices[i];
            pop_heap(begin(heap), end(heap), comp);
            auto [size, sol_index] = heap.back();
            heap.pop_back();
            sol[index] = sol_index + 1;
            heap.emplace_back(size + his[index], sol_index);
            push_heap(begin(heap), end(heap), comp);
        }
        cout << "YES" << endl;
        for(const auto el : sol) cout << " " << el;
        cout << endl;
    }
    return 0;
}