#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define nl "\n"
#define all(x) (x).begin(), (x).end()
#define Yes cout<<"Yes"<<"\n";
#define No cout<<"No"<<"\n";
string concatenate(string a, string b) {
return a + b;
}
void run(int t){
int n,k,m;
cin >> n >> k;
vector<string> a(n);
for(int i = 0;i<n;i++){
cin >> a[i];
}
while (k > 0 && a.size() > 1) {
int max_idx = 0;
string max_concat = concatenate(a[0], a[1]);
for (int i = 1; i < a.size() - 1; i++) {
string concat = concatenate(a[i], a[i+1]);
if (concat > max_concat) {
max_concat = concat;
max_idx = i;
}
}
a[max_idx] = max_concat;
a.erase(a.begin() + max_idx + 1);
k--;
}
string ans = a[0];
for (int i = 1; i < a.size(); ++i) {
if (a[i] > ans) {
ans= a[i];
}
}
cout << ans << nl;
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
cin >> t;
int c = 1;
while(t--){
//cout << "Case " << c++ << ": ";
run(t);
}
return 0;
}