#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio;     cin.tie(NULL);     long long i, j, n, t, k, m;     cin >> t;     while (t--) {       cin >> n >> k;       vector<long long> s(n);       for (long long i = 0; i < n; i++) {         cin >> s[i];       }       map<long long, queue<long long>> m;       for (long long i = 0; i < n; i++) {         m[s[i]].push(i);       }       vector<long long> res(n + 1, 0);       long long ans = 0;       long long count = 0;       long long col = 1;       vector<long long> v;       for (auto i : m) {         if (i.second.size() >= k) {           long long kk = k;           col = 1;           while (!i.second.empty() && kk > 0) {             res[i.second.front()] = col;             col++;             kk--;             i.second.pop();           }         } else {           while (!i.second.empty()) {             v.push_back(i.second.front());             i.second.pop();           }         }       }       if (v.size() >= k) {         long long sz = v.size();         long long st = sz / k;         st = st * k;         long long col = 1;         for (long long i = 0; i < st; i++) {           res[v[i]] = col;           col++;           if (col == k + 1) {             col = 1;           }         }       }       for (long long i = 0; i < n; i++) {         cout << res[i] <<    ;       }       cout <<   n ;     }   }   