#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int t;
cin >> t;
while (t--){
ll n, k, mx = 0;
cin >> n >> k;
string ans = "";
string a[n + 1];
// vector<string> a(n + 1);
vector<ll> b(n + 1);
for (int i = 1; i <= n; i++){
cin >> a[i]; //cout<<a[i]<<' ';
b[i] = a[i].size();
b[i] += b[i - 1];
} //for(auto i:b)cout<<i<<' ';
for (int i = k + 1; i <= n; i++){
mx = max(mx, b[i] - b[i - k - 1]);
}
for (int i = k + 1; i <= n; i++){
ll x = b[i] - b[i - k - 1];
if (mx == x){
string tmp;
for (int j = i - k; j <= i; j++){
tmp += a[j];
}
if (tmp > ans) ans = tmp;
}
}
cout << ans << endl;
}
}