#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#define mod 1000000007
#define ll long long int
using namespace std;
int main()
{
    int t; cin >> t;
    while(t--)
    {
        int n, m, x; cin >> n >> m >>x;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];
        int ans[n];
        vector<int> sum(m);
        //memset(sum,0,sizeof(sum));
        for(int i=0;i<m;i++)
        {
            sum[i]=a[i];
            ans[i]=i+1;
        }
        for(int i=m;i<n;i++)
        {
            int sumindex=std::min_element(sum.begin(),sum.end()) - sum.begin();
            sum[sumindex]+=a[i];
            ans[i]=sumindex+1;
        }
        sort(sum.begin(),sum.end());
        if((sum[m-1]-sum[0])>x) cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(int i=0;i<n;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
        }
    }
    return 0;
}