#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, k, p, q;
int main() {
  long long t;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld %lld", &n, &k);
    string s1, s3[k + 2];
    cin >> s1;
    multiset<char> s2;
    for (long long i = 0; i < n; i++) s2.insert(s1[i]);
    sort(s1.begin(), s1.end());
    char ch1 = s1[0], ch2 = s1[k - 1];
    if (ch1 != ch2) {
      cout << ch2 << endl;
      continue;
    }
    for (long long i = 0; i < n; i++) {
      long long ind = i % k;
      if (i == n - 2) {
        char ch1 = *s2.begin();
        s2.erase(s2.begin());
        char ch2 = *s2.begin();
        s2.erase(s2.begin());
        if (s3[0] == s3[1]) {
          if (ch1 == ch2) {
            s3[0].push_back(ch1);
            s3[1].push_back(ch2);
          } else {
            s3[0].push_back(ch1);
            s3[0].push_back(ch2);
          }
        } else {
          s3[0].push_back(ch1);
          s3[0].push_back(ch2);
        }
        break;
      }
      s3[ind].push_back(*s2.begin());
      s2.erase(s2.begin());
    }
    long long freq[26] = {};
    for (long long i = 0; i < n; i++) freq[s1[i] - 'a']++;
    vector<char> v1;
    v1.push_back(s1[0]);
    long long flag = 0;
    freq[s1[0] - 'a'] -= k;
    for (long long i = 0; i < 26; i++) {
      if (freq[i] <= 0) continue;
      for (long long j = i + 1; j < 26; j++)
        if (freq[j]) flag = 1;
      if (flag) {
        for (long long i = k; i < n; i++) v1.push_back(s1[i]);
        break;
      }
      while (freq[i] > 0) {
        v1.push_back((i + 'a'));
        freq[i] -= k;
      }
    }
    for (auto it : v1) cout << it;
    cout << endl;
  }
}
