n = int(input())


def sam():
    m = int(input())
    l = [int(b) for b in input().split()]
    k = int(input())
    l = list(dict.fromkeys(l))
    for i in range(k):
        mi = min(l)
        l.pop(l.index(mi))
    return mi


for i in range(n):
    print(sam())

eaf5c11180da9abee9090bc06922987baa56790f
<mask token>

<mask token>


def sam():
    m = int(input())
    l = [int(b) for b in input().split()]
    k = int(input())
    l = list(dict.fromkeys(l))
    for i in range(k):
        mi = min(l)
        l.pop(l.index(mi))
    return mi


<mask token>

<mask token>


def sam():
    m = int(input())
    l = [int(b) for b in input().split()]
    k = int(input())
    l = list(dict.fromkeys(l))
    for i in range(k):
        mi = min(l)
        l.pop(l.index(mi))
    return mi


for i in range(n):
    print(sam())

n = int(input())


def sam():
    m = int(input())
    l = [int(b) for b in input().split()]
    k = int(input())
    l = list(dict.fromkeys(l))
    for i in range(k):
        mi = min(l)
        l.pop(l.index(mi))
    return mi


for i in range(n):
    print(sam())
