⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[][] data = new int[n][];
int[] result = new int[n];
for (int i = 0; i < n; i++)
{
int m = in.nextInt();
data[i] = new int[m];
int o = 0;
for (int j = 0; j < m; j++)
{
int l = in.nextInt();
Boolean b = false;
for (int k : data[i])
if (k == l) b = true;
if (!b) data[i][o++] = l;
}
Arrays.sort(data[i]);
result[i] = data[i][data[i].length - in.nextInt()];
}
for (int item : result)
System.out.println(item);
}
}