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