#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) x.begin(),x.end()
ll mod = 1e9+7;
set<ll> S;
void solve()
{
    int n,m,x;
    cin>>n>>m>>x;
    vi V(n);
    f(i,0,n)
        cin>>V[i];
    // sort(all(V));
    set<pair<int,int> > S;
    f(i,1,m+1){
        S.insert({0,i});
    }
    vi ans(n);
    f(i,0,n){
        auto it = S.begin();
        pair<int,int> p;
        p.first+=it->first+V[i];
        p.second=it->second;
        ans[i]=p.second;
        S.erase(S.begin());
        S.insert(p);
    }
    cout<<"YES"<<endl;
    f(i,0,n)
        cout<<ans[i]<<" ";
    cout<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    int k = 1e5;
    for(ll i=2;i<=k;i++)
        S.insert(i*i);
    S.insert(2);
    cin>>t;
    while(t--)
        solve();
}