#include<bits/stdc++.h>
using namespace std;
const long long M=3e5+10,MOD=1000000000;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
vector<int>a(n+1,0);
string p="";
for(int i=1;i<=n;i++){
string s;
cin>>s;
p+=s;
a[i]=(int)s.size();
a[i]+=a[i-1];
}
int maximum_digit=0;
for(int i=1;i<=n;i++){// target to find maximum digit possible
if(i+k<=n)maximum_digit=max(maximum_digit,a[i+k]-a[i-1]);
}
vector<int>pos;
for(int i=1;i<=n;i++){
if(i+k<=n&&a[i+k]-a[i-1]==maximum_digit)pos.push_back(i);
}
vector<string>ans;
for(int x:pos){
string s="";
int l=a[x-1];
while(s.size()<maximum_digit)s+=p[l],l++;
ans.push_back(s);
}
sort(ans.begin(),ans.end());
cout<<ans[ans.size()-1]<<"\n";
}
return 0;
}