#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve() {
ll n, m; cin >> n >> m;
vector<ull> p(n);
rep(i, 0, n) cin >> p[i];
while (m-- && sz(p) > 1) {
ull j = 0;
string max_str = to_string(p[0]) + to_string(p[1]);
ull max_num = stoull(max_str);
rep(i, 0, sz(p) - 1) {
string current_str = to_string(p[i]) + to_string(p[i + 1]);
ull current_num = stoull(current_str);
if (current_num > max_num) {
max_num = current_num;
j = i;
}
}
p[j] = max_num;
p.erase(p.begin() + j + 1);
}
ull result = *max_element(all(p));
cout << result << endl;
}
int main() {
fast;
ll t; cin >> t;
while (t--) {
solve();
}
return 0;
}