#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (k == 1)
      cout << s << "\n";
    else {
      if (s[k - 1] == s[0]) {
        if (s[k] == s[n - 1]) {
          long long total = (n - 1) / k;
          cout << s[0];
          for (long long i = 0; i < total; i++) cout << s[k];
          cout << "\n";
        } else {
          cout << s[0];
          for (long long i = k; i < n; i++) cout << s[i];
          cout << "\n";
        }
      } else {
        cout << s[k - 1] << "\n";
      }
    }
  }
}
