#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    map<char, long long int> cnt;
    for (long long int i = 0; i < n; i++) {
      cnt[s[i]]++;
    }
    if (k == 1) {
      cout << s << endl;
      continue;
    }
    if (cnt.size() == 1) {
      long long int z = n / k;
      if (n % k != 0) {
        z++;
      }
      for (long long int i = 0; i < z; i++) {
        cout << s[0];
      }
      cout << endl;
      continue;
    }
    if (cnt[s[0]] < k) {
      cout << s[k - 1] << endl;
      continue;
    }
    if (cnt[s[0]] == k && cnt.size() == 2) {
      cout << s[0];
      long long int z = (n - k) / k;
      if ((n - k) % k != 0) {
        z++;
      }
      for (long long int i = 0; i < z; i++) {
        cout << s[k];
      }
      cout << endl;
      continue;
    }
    cnt[s[0]] = cnt[s[0]] - k + 1;
    for (auto i : cnt) {
      for (long long int j = 0; j < i.second; j++) {
        cout << i.first;
      }
    }
    cout << endl;
  }
}
