#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s[1005];
void solve() {
int n,k;
cin >> n >> k;
for(int i = 0; i < n; i++) {
cin >> s[i];
}
string ans;
for(int i = 0; i+k < n; i++) {
string now;
for(int j = i; j <= i+k; j++)
now += s[j];
ans = max(ans,now);
}
cout << ans << '\n';
return;
}
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int tc = 1;
cin >> tc;
for(int kase = 1; kase <= tc; kase++) {
//cout << "Case " << kase << ": ";
solve();
}
return 0;
}