#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
#include "ctime"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
const int P = 1e9 + 7;
int n , m , x;
int A[MAXN] , as[MAXN];

multiset<pii> S;

void solve() {
	cin >> n >> m >> x;
	S.clear();
	rep( i , 1 , m ) S.insert( mp( 0 , i ) );
	rep( i , 1 , n ) {
		scanf("%d",A + i);
		as[i] = S.begin() -> se;
		S.insert( mp( ( S.begin() -> fi ) + A[i] , S.begin() -> se ) );
		S.erase( S.begin() );
	}
	puts("YES");
	rep( i , 1 , n ) printf("%d ",as[i]); puts("");
}

signed main() {
   int T;cin >> T;while( T-- ) solve();
//	solve();
}
