#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define nl "\n"
#define testcase ll t;cin>>t;while(t--)
#define f(i,n) for(i=0;i<n;i++)
typedef pair<ll,ll>ii;
typedef vector<ll>vi;
typedef vector<ii>vii;
typedef vector<vi>vvi;
typedef vector<long long>vl;
typedef vector <vl>vvl;
template<class T>
void print(T& a)
{
    for(auto x:a)
        cout<<x<<" ";
    cout<<"\n";
}
int main()
{

    FastIO
    ll n,i,m,x;
    testcase
    {
        cin>>n>>m>>x;
        vii v;
        ll k;
        f(i,n)
        {
           cin>>k;
           v.pb({k,i});
        }
        sort(All(v));
        ll ans[n+2];
        f(i,n)
        {
            ans[v[i].second]=(i%m)+1;
        }
        cout<<"YES"<<nl;
        for(i=0;i<n;i++)
        cout<<ans[i]<<" ";
        cout<<nl;
    }


    return 0;
}