#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(const string &a, const string &b) {
return a + b;
}
struct Compare {
bool operator()(const pair<string, int> &a, const pair<string, int> &b) {
return a.first < b.first;
}
};
void run(int t){
int N, K;
cin >> N >> K;
vector<string> a(N);
for (int i = 0; i < N; ++i) {
cin >> a[i];
}
priority_queue<pair<string, int>, vector<pair<string, int>>, Compare> maxHeap;
for (int i = 0; i < N - 1; ++i) {
string concat1 = concatenate(a[i], a[i + 1]);
maxHeap.push({concat1, i});
}
for (int i = 0; i < K; ++i) {
if (maxHeap.empty()) break;
auto [maxConcat, index] = maxHeap.top();
maxHeap.pop();
a[index] = maxConcat;
a.erase(a.begin() + index + 1);
if (index > 0) {
string concat1 = concatenate(a[index - 1], a[index]);
maxHeap.push({concat1, index - 1});
}
if (index < a.size() - 1) {
string concat2 = concatenate(a[index], a[index + 1]);
maxHeap.push({concat2, index});
}
}
cout << *max_element(all(a)) << 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;
}