#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, d;
    cin >> n >> d;
    string s;
    cin >> s;
    string temp = s;
    sort(temp.begin(), temp.end());
    if (d == 1) {
      cout << temp << endl;
      continue;
    }
    string res = "";
    int i = 0;
    if (temp[i] == temp[i + d - 1]) {
      res += temp[i + d - 1];
      i = d;
    } else {
      cout << temp[i + d - 1] << endl;
      continue;
    }
    string alt = res + temp.substr(i, temp.size() - i);
    while (i < temp.size()) {
      if ((i + d) > temp.size()) {
        res += temp[temp.size() - 1];
        break;
      }
      if (temp[i + d - 1] == temp[i]) {
        res += temp[i];
        i = i + d;
      } else {
        string ans = res + temp.substr(i, temp.size() - i);
        res = ans;
        break;
      }
    }
    if (alt < res) {
      cout << alt << endl;
    } else {
      cout << res << endl;
    }
  }
}
