#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e5 + 9;
const int inf = 3e10 + 9;
int a[N], b[N];
int dp[1003][103];
string s[N];
vector<int> v[7];
std::map<string, int> mp;
int32_t main() {
int tc = 1;
cin >> tc;
while(tc--) {
int n, k; cin >> n >> k;
for (int i = 0; i < n; ++i)
{
cin >> s[i];
}
string ans = "";
for(int i = 0; i < n; i++)
{
string tmp = "";
for(int j = i; j <= i + k; j++)
{
tmp += s[j];
}
ans = max(ans, tmp);
}
cout << ans << endl;
}
return 0;
}