#include <bits/stdc++.h>
using namespace std;
#define qc ios::sync_with_stdio(0)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
//#define int ll
typedef pair<int, int> Pair;
int a[100001];
int ans[100001];

signed main() {
	qc, cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		priority_queue<Pair, vector<Pair>, greater<Pair> >q;
		int n, m, x;
		cin >> n >> m >> x;
		for (int i = 1; i <= m; i++)
			q.push(mp(0, i));
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			int s = q.top().fi, p = q.top().se;
			q.pop(), ans[i] = p;
			q.push(mp(s + a[i], p));
		}
		cout << "YES\n";
		for (int i = 1; i <= n; i++)
			cout << ans[i] << " ";
		cout << "\n";
	}
}
