#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define ll              unsigned long long
#define endl            "\n"
#define pb              push_back
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void pre_fast()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n, m, x; cin >> n >> m >> x;

	//vector<int> arr(n);
	int arr;
	set<pair<int, int> > s;

	cout << "YES\n";

	for (int i = 1; i <= m; i++)
	{
		s.insert({0, i});
	}

	for (int i = 0; i < n; i++)
	{
		cin >> arr;

		auto p = *s.begin();
		s.erase(p);
		cout << p.second << " ";
		s.insert({p.first + arr, p.second});
	}
}

int32_t main()
{
	pre_fast();
	int t;	cin >> t;
	while (t--)
	{
		solve();
		cout << endl;
	}
}
