#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  while (test--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    string ans[k];
    for (long long i = 0; i < k; i++) {
      ans[i].resize(1);
      ans[i][0] = s[i];
    }
    if (ans[0] != ans[k - 1]) {
      cout << ans[k - 1] << "\n";
      continue;
    }
    long long f1 = 0;
    for (long long i = k + 1; i < n; i++) {
      if (s[i] != s[i - 1]) {
        f1 = 1;
        break;
      }
    }
    if (f1) {
      cout << ans[0];
      for (long long i = k; i < n; i++) cout << s[i];
      cout << "\n";
      continue;
    } else {
      if (n % k == 0) {
        cout << ans[0];
        for (long long i = 0; i < (n - k) / k; i++) {
          cout << s[k];
        }
        cout << "\n";
      } else {
        cout << ans[0];
        for (long long i = 0; i < ((n - k) / k) + 1; i++) {
          cout << s[k];
        }
        cout << "\n";
      }
    }
  }
}
