#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 228;
const long long mod = (long long)(1e9 + 7);
const long long INF = (long long)(1e18 + 7);
const double PI = 3.141592653589793238462643;
string s1[200000];
int main() {
  int ttt;
  int n, k;
  cin >> ttt;
  string s;
  while (ttt--) {
    cin >> n >> k >> s;
    for (int i = 0; i < n; i++) s1[i] = "";
    sort(s.begin(), s.end());
    if (k == 1) {
      cout << s << "\n";
      continue;
    }
    int cnt2 = 1;
    for (int i = 0; i < n; i++) {
      if (i >= 1 && s[i] != s[i - 1]) {
        cnt2++;
      }
    }
    for (int i = 0; i < k; i++) {
      s1[i] += s[i];
    }
    if (s1[0] != s1[k - 1])
      cout << s1[k - 1] << "\n";
    else {
      if (cnt2 == 1) {
        for (int i = 0; i <= (n - 1) / k; i++) cout << s1[k - 1];
        cout << "\n";
        continue;
      }
      if (cnt2 == 2 && k < n && s[k] != s[k - 1]) {
        cout << s1[k - 1];
        for (int i = 1; i <= (n - 1) / k; i++) cout << s[n - 1];
        cout << "\n";
        continue;
      }
      for (int i = k; i < n; i++) s1[k - 1] += s[i];
      cout << s1[k - 1] << "\n";
    }
  }
  return 0;
}
