#include <iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string.h>
using namespace std;
int main(){
int t; cin>>t;
while(t--){
int n; cin>>n;
int k; cin>>k;
vector<int>v(n);
for(auto i:v)cin>>v[i];
sort(v.begin(),v.end());
for(int i=0;i<n;i++){
auto res = upper_bound(v.begin(),v.end(),v[i])-v.begin();
auto res2 = lower_bound(v.begin(),v.end(),v[i])-v.begin();
if(res-res2 >= k){cout<<v[i]<<endl;}
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxzZXQ+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxjbWF0aD4KI2luY2x1ZGU8c3RyaW5nLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKXsKaW50IHQ7IGNpbj4+dDsKd2hpbGUodC0tKXsKICAgIGludCBuOyBjaW4+Pm47CiAgICBpbnQgazsgY2luPj5rOwogICAgdmVjdG9yPGludD52KG4pOwogICAgZm9yKGF1dG8gaTp2KWNpbj4+dltpXTsKICAgIHNvcnQodi5iZWdpbigpLHYuZW5kKCkpOwoKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGF1dG8gcmVzID0gdXBwZXJfYm91bmQodi5iZWdpbigpLHYuZW5kKCksdltpXSktdi5iZWdpbigpOwogICAgICAgIGF1dG8gcmVzMiA9IGxvd2VyX2JvdW5kKHYuYmVnaW4oKSx2LmVuZCgpLHZbaV0pLXYuYmVnaW4oKTsKICAgICAgICBpZihyZXMtcmVzMiA+PSBrKXtjb3V0PDx2W2ldPDxlbmRsO30KICAgIH0KCgoKCn0KfQo=