#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t) {
    t--;
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] != s[k - 1] || k == n)
      cout << s[k - 1];
    else if (s[k] != s[n - 1])
      for (int i = k - 1; i < n; i++) cout << s[i];
    else {
      cout << s[k - 1];
      int t = (n - 1) / k;
      for (int i = 0; i < t; i++) cout << s[n - 1];
    }
    cout << endl;
  }
  return 0;
}
