#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define nl "\n"
#define all(x) (x).begin(), (x).end()
#define Yes cout<<"Yes"<<"\n";
#define No cout<<"No"<<"\n";
string concat(const string &a, const string &b) {
return a + b;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int N, K;
cin >> N >> K;
vector<string> arr(N);
for (int i = 0; i < N;i++) {
cin >> arr[i];
}
priority_queue<pair<string, pair<int, int>>> pq;
for (int i = 0; i < N - 1; i++) {
pq.push({concat(arr[i], arr[i + 1]), {i, i + 1}});
}
for (int i= 0; i< K; i++) {
if (pq.empty()) break;
auto top = pq.top();
pq.pop();
string new_value = top.first;
int index1 = top.second.first;
int index2 = top.second.second;
arr[index1] = new_value;
arr.erase(arr.begin() + index2);
if (index1 > 0 && index1 < arr.size()) {
pq.push({concat(arr[index1 - 1], arr[index1]), {index1 - 1, index1}});
}
if (index1 + 1 < arr.size()) {
pq.push({concat(arr[index1], arr[index1 + 1]), {index1, index1 + 1}});
}
}
string max_value;
for (const auto &value : arr) {
if (value > max_value) {
max_value = value;
}
}
cout << max_value << '\n';
}
return 0;
}