#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    vector<int> cnt(26, 0);
    for (auto c : s) cnt[c - 'a']++;
    string ans = "";
    for (int i = 0; i < k; ++i) {
      cnt[s[i] - 'a']--;
    }
    ans += s[k - 1];
    if (s[k - 1] != s[0]) {
      cout << ans << endl;
      continue;
    }
    for (int i = k; i < n; i++) {
      if ((i + k - 1) >= n) {
        if (s[i] != s[n - 1]) {
          for (int j = i; j < n; ++j) {
            ans += s[j];
          }
        } else {
          int times = ((n - i) / k) + !!((n - i) % k);
          while (times--) {
            ans += s[i];
          }
        }
        break;
      }
      if (s[n - 1] == s[i]) {
        int times = ((n - i) / k) + !!((n - i) % k);
        while (times--) {
          ans += s[i + k - 1];
        }
        break;
      } else {
        for (int j = i; j < n; j++) {
          ans += s[j];
        }
        break;
      }
    }
    cout << ans << endl;
  }
}
