#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> PII;
const ll mx = 3e5+10;
ll Concat(ll a, ll b) {
ll Mul = 1;
while(Mul <=b) Mul*=10;
return a*Mul + b;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin>>t;
while(t--) {
ll n, k;
cin >> n >> k;
vector<ll> Vec(n);
for(int i=0; i<n; i++) cin >> Vec[i];
while(k>0 and n>1) {
ll Max = LONG_MIN;
int Id = -1;
for(int i=0; i<n-1; i++) {
ll Pair = Concat(Vec[i],Vec[i+1]);
if(Pair > Max) {
Max = Pair;
Id = i;
}
}
if(Id != -1) {
Vec[Id] = Max;
Vec.erase(Vec.begin() + Id + 1);
n--;
}
k--;
}
cout<<*max_element(Vec.begin(), Vec.end())<<endl;
}
}