#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int64_t t;
  cin >> t;
  while (t--) {
    int64_t n, m;
    string s;
    cin >> n >> m >> s;
    sort(s.rbegin(), s.rend());
    vector<string> v(m), v2(m);
    int64_t idx = m - 1;
    for (int64_t i = 0; i < n; ++i) {
      if (i < n - m) {
        v[0] += s[i];
      } else {
        v[idx] += s[i];
        idx--;
      }
    }
    for (auto& i : v) reverse(begin(i), end(i));
    sort(v.rbegin(), v.rend());
    reverse(s.begin(), s.end());
    for (int64_t i = 0; i < n; ++i) {
      v2[i % m] += s[i];
    }
    sort(v2.rbegin(), v2.rend());
    cout << min(v2[0], v[0]) << '\n';
  }
  return 0;
}
