#include <bits/stdc++.h>
using namespace std;
const int idata = 1e6 + 5;
const int inf = 0x3f3f3f3f;
int n, m, t, _;
int i, j, k;
int cnt, num;
int maxx = -1, minn = inf;
vector<int> v;
string s, ans;
int main() {
  cin.tie(0);
  iostream::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    bool judge = 0;
    cin >> n >> k;
    cin >> s;
    sort(s.begin(), s.end());
    ans.clear();
    if (s[0] == s[k - 1]) {
      if (s[k] == s[n - 1])
        ans = s[0] + s.substr(k, (n - 1) / k);
      else
        ans = s.substr(k - 1, n - k + 1);
    } else {
      ans = s[k - 1];
    }
    cout << ans << endl;
  }
  return 0;
}
