//使用set的查重功能
//再逆向迭代器一下
#include<iostream>
#include<set>
using namespace std;
int T, N, K;
int main(){
cin >> T;
while(T--) {
set<int> set;
cin >> N;
for(int j = 0; j < N; j++) {
int num;
cin >> num;
set.insert(num);
}
cin >> K;
std::set<int>::iterator it = set.end();
while(K--) it--;
cout << *it << endl;
}
return 0;
}
//presented by 大吉大利,今晚AC