#include <bits/stdc++.h>
using namespace std;
string solve(int n, int k, vector<string>& arr) {
priority_queue<pair<string, int>> pq;
for (int i=0; i<n-1; i++){
string concat=arr[i]+arr[i+1];
pq.push({concat,i});
}
for (int i=0; i<k && !pq.empty(); i++) {
auto top=pq.top();
pq.pop();
string max_con = top.first;
int pos = top.second;
arr[pos] = max_con;
arr.erase(arr.begin()+pos+1);
if (pos>0) {
string concat =arr[pos-1]+arr[pos];
pq.push({concat,pos-1});
}
if (pos<arr.size()-1) {
string concat=arr[pos]+arr[pos+1];
pq.push({concat,pos});
}
--n;
}
return *max_element(arr.begin(), arr.end());
}
int main() {
int t;
cin>>t;
while(t--) {
int n,k;
cin>>n>>k;
vector<string> str(n);
for(int i=0; i<n; i++) {
cin>>str[i];
}
cout << solve(n, k, str) << endl;
}
return 0;
}