/*
**************************************************************
*Bis'Millah Hir Rah'Manir Rahim == start with the name of \n *
* ALLAH Subhana Tayala *
* Author: Md. Mahabubar Rahman *
* CSE,RPI && Rangpur, Bangladesh *
**************************************************************
*/
#include <bits/stdc++.h>
using namespace std;
#define Allhamdulillah 0
#define pb(x) push_back(x)
#define pp() pop_back()
#define ll long long int
#define foi(i, s, e) for (int i = s; i < e; i++)
#define cn(x) cin >> x
#define endl '\n'
#define Endl '\n'
#define nl cout << '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n"
int sss(int n){
string s=to_string(n);
return s.size();
}
void solve()
{
int n,k;cin>>n>>k;int arr[n];for(auto &c:arr)cin>>c;
vector<string>ans;
string s="",s2;
for(int i=0;i<=k;i++)s+=to_string(arr[i]);
int start=1,j=k+1;
ans.push_back(s);
while(j<n){
s+=to_string(arr[j]);
int dlt=sss(arr[start-1]),tt=s.size();
s2=s.substr(dlt,tt-dlt);
ans.push_back(s2);
s=s2;
start++;
j++;
}
sort(ans.begin(),ans.end(),greater<string>());
cout<<ans[0]<<endl;
}
/*mdmahabub55*/
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
cin >> t;
// t = 1;
while (t--)
{
solve();
}
return Allhamdulillah;
}