#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(a) cout << #a << " : " << a << endl;
void solve()
{
int n, k; cin >> n >> k;
string s; cin >> s;
deque<char> dq;
map<char,vector<int>> mp;
for(int i = 0; i < n; i++) {
dq.push_back(s[i]);
mp[s[i]].push_back(i);
}
if (k >= n){
sort( s.begin(), s.end() );
cout << s << '\n';
return;
}
vector<char> ans;
int l = 0;
for(auto x : mp){
char ch = x.first;
int cnt = x.second.size();
int mx = cnt;
deque<pair<char,int>> tmp;
while( l < n and k and cnt ) {
if ( dq[l] == ch ) {
l++;
continue;
}
if ( l > x.second.back() ) break;
tmp.push_back({dq[l], l});
l++;
k--;
cnt--;
}
mx -= cnt;
//return;
sort( tmp.begin(), tmp.end() );
// for(auto x : tmp) cout << x;
//cout << '\n';
auto idx = x.second;
while( !idx.empty() ) {
if ( tmp.empty() ) break;
s[tmp.back().second] = ch;
s[idx.back()] = tmp.back().first;
dq[idx.back()] = tmp.back().first;
tmp.pop_back();
idx.pop_back();
}
if ( !k ) break;
if ( l == n ) break;
}
for(int i = l; i < n; i++) s[i] = dq[i];
cout << s << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1, tc = 0;
cin >> t;
while(t--){
//cout << "Case " << ++tc << ": ";
solve();
}
}