#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
void solve() {
int n, k;
cin >> n >> k;
vector<string> arr(n);
for(int i = 0; i < n; i++) {
cin >> arr[i];
}
while(k > 0 && arr.size() > 1) {
string max_concat = "";
int max_index = 0;
for(int j = 0; j < arr.size() - 1; j++) {
string concat1 = arr[j] + arr[j + 1];
if(concat1 > max_concat) {
max_concat = concat1;
max_index = j;
}
}
// Perform the best concatenation
arr[max_index] = max_concat;
arr.erase(arr.begin() + max_index + 1);
k--;
}
// Find the maximum element in the resulting array
string max_element_in_array = *max_element(arr.begin(), arr.end());
cout << max_element_in_array << endl;
}
signed main() {
fastio;
int t;
cin >> t;
while (t--) {
solve();
}
}