#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define inp(a, n)           \
    for (ll j = 0; j < n; j++) \
        cin >> a[j];
#define lp(i, t, n) for (ll i = t; i < n; i++)
#define alp(i, a) for (auto i : a)
#define rev(i, t, n) for (ll i = t; i >= n; i--)

#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pb push_back
#define nl "\n"
#define sz(a) long long((a).size())
#define all(c) c.begin(),c.end()
#define vll vector<ll>
#define vch vector<char>
#define vvll vector<vector<ll>>
#define ii pair<ll,ll>
#define vii vector<pair<ll,ll>>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define usll unordered_set<ll>
#define mp make_pair
#define vbool vector<bool>
#define mod 1000000007
#define ff first
#define ss second
#define test  \
    ll t;    \
    cin >> t; \
    while (t--)
#define MAX (ll) 1e18
#define MIN (ll) -1e18
using namespace std;


void solve(){
    ll n , m , x;
    cin>>n>>m>>x;
    vii a(n);
    lp( i , 0 , n) cin>>a[i].ff , a[i].ss = i;
    sort(all(a));
    vll ans(n);
    lp( i , 0 , n){
        ans[a[i].ss] = i%m +1; 
    }
    cout<<"YES"<<nl;
    alp( i ,  ans) cout<<i<<" "; cout<<nl;
}

int main(){
    IOS
    test
    solve();
}