#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sp " "
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
void messi()
{
ll n, k;
cin >> n >> k;
vector<string> v(n);
for (string &x : v)
cin >> x;
string ans = "";
while (k > 0 && n > 1)
{
ll index = 0;
ans = v[0] + v[1];
for (ll i = 1; i < n - 1; i++)
{
string con = v[i] + v[i + 1];
if (con > ans)
{
ans = con;
index = i;
}
}
v[index] = ans;
v.erase(v.begin() + index + 1);
n--;
k--;
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
ll tc = 1;
cin >> tc;
while (tc--)
{
messi();
}
return 0;
}