#include <bits/stdc++.h>
using namespace std;
#define db long long
#define ll long long
#define int ll
#define vi vector<int>
#define vs vector<string>
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define vps vector<pair<string, string>>
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define pp(x) pop_back(x)
#define fr(cont) for (auto &i : (cont))
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define mo(a, b) (((a) % (b)) + (b)) % (b)
#define endl '\n'
void solve()
{
/*
1. Think Greedy
2. Think Brute Force
3. Think solution in reverse order
4. Think DP [ check constraints carefully ]
5. Check base cases for DP and prove solution for Greedy
6. Think Graph
*/
int n,k;
cin>> n >> k;
vector<string>vc(n);
vi ans;
fr(vc)cin >> i;
for(int i = 0;i <= n-(k+1);i++)
{
string s = "";
for(int j = i;j <= i+k;j++)
s += vc[j];
ans.pb(stoll(s));
}
sort(rall(ans));
cout << ans[0] << endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// auto st = clock();
int t = 1;
cin >> t;
for(int i = 1;i <= t;i++)
{
// cout << "Case " << i << ": ";
solve();
}
// cerr << 1.0*(clock()-st)/CLOCKS_PER_SEC << endl;
return 0;
}
/*Problem_link
*/