
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265
#define pb push_back
#define en cout<<'\n'
#define vec vector<ll>
#define vecs vector<string>
#define pii pair<ll,ll>
#define VP vector< pii >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define mm " "
#define MM " "
#define mll map<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fa(x,v) for(auto x:v)
#define INF (ll)(9e18)
#define Sort(v) sort(v.begin(),v.end())
#define rsort(v) sort(v.rbegin(),v.rend())
#define test ll T;cin>>T;while(T--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define db4(x,y,z,w) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<","<<#w<<"="<<w<<'\n'
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(a,max3(b,c,d))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define maxi(a) *max_element(a,a+n)
#define mini(a) *min_element(a,a+n)
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define no2 cout << "No" << endl
#define yes2 cout << "Yes" << endl
#define mxheap    priority_queue<int>
#define mnheap    priority_queue<int,vector<int>,greater<int>>
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
 const ll MOD=1000000000+7;
const ll MOD1 = 998244353;

string itos(ll s)
{
string str=to_string(s);
return str;
}
ll stoi2(string s)
{
    ll a= atoi(s.c_str());
    return a;
}
template <typename T>
void read(T &p)
{
    cin >> p;
}
 
template <typename T, typename T1>
void read(pair<T, T1> &p)
{
    read(p.ff);
    read(p.ss);
}
 
template <typename T>
void read(T arr[], ll n)
{
    for (ll i = 0; i < n; i++)
    {
        read(arr[i]);
    }
}
 
template <typename T>
void read(vector<T> &arr)
{
    for (ll i = 0; i < arr.size(); i++)
    {
        read(arr[i]);
    }
}
//////////////////////////////////////
 
template <typename T>
void out(T& n)
{
    cout << n;
}
 
template <typename T, typename T1>
void out(pair<T, T1> &p)
{
    cout << "(";
    out(p.ff);
    cout << ",";
    out(p.ss);
    cout << ")";
    cout<<endl;
}
 
template <typename T>
void out(T arr[], ll n)
{
    for (ll i = 0; i < n; i++)
    {
        out(arr[i]);
        cout << " ";
    }
    cout<<endl;
}
 
template <typename T>
void out(vector<T> &arr)
{
 
    for (ll i = 0; i < arr.size(); i++)
    {
        out(arr[i]);
        if (i!=arr.size()-1)
            cout << " ";
    }
    cout<<endl;
 
}
 
 
 
template <typename T>
void out(set<T> &arr)
{
    for (auto i:arr)
    {
        out(i);
        cout << " ";
    }
    cout<<endl;
}
 
template <typename T>
void out(multiset<T> &arr)
{
    for (auto i:arr)
    {
        out(i);
        cout << " ";
    }
    cout<<endl;
}
 
template <typename T, typename T1>
void out(map<T,T1> &m)
{
    for (auto i:m)
    {
        out(i.first);
        cout<<" -> ";
        out(i.second);
        cout<<", ";
    }
    cout<<endl;
}
ll powerm(ll a, ll b, ll MOD) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

ll power(ll a, ll b) {
   
  ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}

bool isSubSequence(string str1, string str2, int m, int n)
{

    if (m == 0) return true;
    if (n == 0) return false;

    if (str1[m-1] == str2[n-1])
        return isSubSequence(str1, str2, m-1, n-1);

    return isSubSequence(str1, str2, m, n-1);
}


bool ispalindrome(ll len,string str)
{
 
    for(int i = 0; i < len/2; i++){
        if(str[i] != str[len-1-i]){
            return false;
        }
    }
    return true;
}
inline bool isPowerOfTwo(ll x)
{
    return ((1LL << (ll)log2(x)) == x);
}
ll isprime(ll N){
    if(N<2 || (!(N&1) && N!=2))
        return 0;
    for(ll i=3; i*i<=N; i+=2){
        if(!(N%i))
            return 0;
    }
    return 1;
}
vec factor;
void factors(ll n)
{
    
for(ll i=1;i<=sqrt(n);i++)
{
    if(n%i==0)
    {
        if(i==n/i)
        factor.pb(i);
        else
        {
            factor.pb(i);
            factor.pb(n/i);
        }
        
    }
}
 
sort(all(factor));
}
ll gcd(ll a, ll b) { 
   if (b == 0)  
      return a; 
   return gcd(b, a % b);  
}
ll lcm(ll a,ll b)
{
    return (a/gcd(a,b))*b;
}
bool isvalid(ll i,ll j,ll n)
{
    if(i>=0&&i<n&&j>=0&&j<n)return true;
    return false;
}
ll dx[8]={0,1,1,1,0,-1,-1,-1};
ll dy[8]={-1,-1,0,1,1,1,0,-1};


ll binarytodecimal(string n)
{
    string num = n;
    ll dec_value = 0;
 
   ll base = 1;
 
   ll len = num.length();
    for (int i = len - 1; i >= 0; i--) {
        if (num[i] == '1')
            dec_value += base;
        base = base * 2;
    }
 
    return dec_value;
}
ll extended_GCD(ll a , ll b , ll &x , ll &y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b % a , a , x1 , y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod = MOD) {
    ll x , y;
    extended_GCD(a , mod , x , y);
    if (x < 0) x += mod;
    return x;
}
string dtb(ll  n )
{

    string s="";

    while(n>0){

    if(n%2==0)s.pb('0');
    else s.pb('1');
    n/=2;

    }

    reverse(all(s));
//       while(s.size()<siz)
//    {
//
//        s='0'+s;
//
//    }
    return s;
}
ll getfactorisation(ll n)
{
ll N=5e6+5;
  vector<ll>fact(N);
  for(int i=0;i<N;i++)fact[i]=i;
  for(int i=2;i<N;i+=2)fact[i]=2;
      for (ll i=3;i<= N ;i+= 2)
       if (i==fact[i])
        for (ll j=i*i ; j<N;j+= i)
         if (fact[j]== j)fact[j] = i;

vec res;
  while(n>1)
  {
     res.pb(fact[n]);
      n/=fact[n];


  }
  return res.size();
}

long long maxPrimeFactor(long long n) 
{ 
    long long maxPrime = -1; 
  
    while (n % 2 == 0) { 
        maxPrime = 2; 
        n >>= 1; // equivalent to n /= 2 
    } 
  
    for (int i = 3; i <= sqrt(n); i += 2) { 
        while (n % i == 0) { 
            maxPrime = i; 
            n = n / i; 
        } 
    } 
  
    if (n > 2) 
        maxPrime = n; 
  
    return maxPrime; 
} 

vec seive;
void Seive() {
    const ll maxn = 1e6 + 5;
    seive.resize(maxn);
    f(i,0, maxn) seive[i] = i;
    for(ll i=2;i<=maxn;i+=2)
    seive[i] = 2;
    seive[1] = -1;
    seive[0] = -1;
    for (ll i = 3; i <= maxn; i += 2)
        if (i == seive[i])
        for (ll j = i * i ; j < maxn ; j += i)
        if (seive[j] == j)
        seive[j] = i;
}
//cout<<"Case #"<<t<<": ";
// check integer overflow(s->x+y--s<x)
void factorisation(ll n)
{
vec res;
     for(ll i=2;i*i<=n;i++) {
            if (n%i==0) {
                while (n%i==0) {
                    n/=i;
                   res.pb(i);
                }
            }
        }
        if (n>1)
            res.pb(n);

}
 int numOfDivisors[100005]={0};
   void noOfDivisor(){
    for(int i=1;i<=100005;i++)
        for(int j=i;j<=100005;j+=i){
            numOfDivisors[j]++;
        }
}

ll fac[200005];
unsigned long long modInverse(unsigned long long n,  
                                            int p)
{
    return powerm(n, p - 2, p);
}
  long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
    if (n < r)
        return 0;
    if (r == 0)
        return 1;
 unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;
 
    return (fac[n] * modInverse(fac[r], p) % p
            * modInverse(fac[n - r], p) % p)
           % p;
}

int main()
{
fast;

 
 ll T=1;
  cin>>T;
while(T--)
{
  ll n,m,x;
  cin>>n>>m>>x;
  vec v(n,0);
  ll sum=0;
  f(i,0,n)cin>>v[i],sum+=v[i];

  VP p;
  f(i,0,n)
  {
    p.pb({v[i],i});
  }
  Sort(p);
  reverse(all(p));
  mll mp;
   ll cur=1;
   for(int i=0;i<n;i++)
   {
        mp[p[i].ss]=cur;
        cur++;
        if(cur>m)cur=1;
   }
   yes;
   f(i,0,n)
    cout<<mp[i]<<MM;
en;


}















    
}
