#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nl '\n'
int main() {
int t; cin >> t;
while(t--){
ll n,k; string s, t, ans; cin >> n >> k >> s;
t = s;
ans = s;
sort(t.begin(), t.end());
map<char, set<int>> mp, lagbe;
for(int i=0;i<n;++i) mp[s[i]].insert(i);
for(int i=0;i<n;++i) lagbe[t[i]].insert(i);
for(auto [c, v]: lagbe){
int mx = *v.rbegin();
while(mp[c].size() and *mp[c].begin() <=mx){
mp[c].erase(*mp[c].begin());
}
vector<int> sw;
vector<char> chr;
int cnt = 0;
while(mp[c].size() and k){
sw.push_back(*mp[c].rbegin());
mp[c].erase(*mp[c].rbegin());
--k;
cnt++;
}
for(int i=*v.begin();i<=*v.rbegin() and cnt;++i)
if(s[i]!=c)
chr.push_back(s[i]),mp[s[i]].erase(i),cnt--, s[i] = c;
sort(sw.begin(), sw.end());
sort(chr.begin(), chr.end());
for(int i=0;i<sw.size();++i) {
s[sw[i]] = chr[i];
mp[s[sw[i]]].insert(sw[i]);
}
// cerr << s << nl;
}
cout << s << nl;
}
}