#include<bits/stdc++.h>
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ll long long int
#define all(u) sort(u.begin(),u.end())
#define nxt(u) next_permutation(u.begin(),u.end())
#define rev(u) reverse(u.begin(),u.end())
#define cinv(u) for(auto &it : u) cin >> it;
#define pb push_back
#define Which would be worse
#define siz(st) st.size()
#define nl "\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n";
#define pii pair < int , int >
#define v vector
#define For(s , e , k) for(int i = s ; i <= e ; i += k)
#define print(s , e , k , ar) for(int i = s ; i <= e ; i += k) cout << ar[i] << " \n"[i == e]
using namespace std;
//#ifndef ONLINE_JUDGE
//#include "template.h"
//#endif
const int fx[]={-1,0,1,0};
const int fy[]={0,1,0,-1};
const int sz = 2e5 + 10 ;
//cout<<"Case "<<t<<": "<<ans<<endl;
//priority_queue <ll, vector<ll>, greater<ll> > pq;//soto theke boro
//cout<<setprecision(10)<<fixed;
// ll id=lower_bound(de.begin(),de.end())-de.begin();
/*remainder extra space*/
void solve(){
int n , k;
cin >> n >> k ;
v < string > ar(n) , de;
For(0 , n - 1 , 1){
cin >> ar[i];
}
for(int i = 0 ; i < n ; i++){
string s ;
for(int j = i ; j < n && j <= i + k ; j++){
s += ar[j];
}
de.push_back(s);
}
int mx = 0 ;
string s = "0";
for(auto &i : de){
string r = i ;
int sz = r.size();
mx = max(mx , sz);
}
for(auto &i : de){
string r = i ;
int sz = r.size();
if(sz == mx){
s = max(s , r);
}
}
cout << s << "\n";
}
int main(){
fastio;
int T = 1;
cin >> T;
while(T--)
solve();
}