#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using LL = long long;
int main() {
cin.tie (nullptr) -> ios_base :: sync_with_stdio (false);
int tests;
cin >> tests;
while (tests--) {
int n, k;
cin >> n >> k;
vector <int> pref (n + 1);
string text = "";
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
text += s;
pref[i] = s.size () + pref[i - 1];
}
vector <string> v;
for (int i = 0; i + k + 1 <= n; i++) {
string s = text.substr (pref[i], pref[i + k + 1] - pref[i]);
v.push_back (s);
}
sort (all (v));
sort (all (v), [&] (string a, string b) {
if (a.size () == b.size ()) return a < b;
return a.size () < b.size ();
});
// for (auto c : v) cerr << c << endl;
cout << v.back () << '\n';
}
return 0;
}