#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<char> vec(n);
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    if (str[0] != str[k - 1]) {
      cout << str[k - 1] << '\n';
      continue;
    }
    cout << str[0];
    if (str[k] != str.back())
      cout << str.substr(k, n - k);
    else
      for (long long i = 0; i < (n - 1) / k; ++i) cout << str.back();
    cout << '\n';
  }
  return 0;
}
