X, N = list(map(int, input().split()))

*P, = list(map(int, input().split()))

l = set([i for i in range(-200, 200)]) - set(P)

m = 100000000

ans = 0

for i in l:

    if abs(i-X) < m:

        ans = i

        m =abs(i - X)

print(ans)
X, N = list(map(int, input().split()))

*P, = list(map(int, input().split()))

l = set(range(-200, 200)) - set(P)

m = 10 ** 7

ans = 0

for i in l:

    if abs(i - X) < m:

        ans = i

        m = abs(i - X)

print(ans)

X, N = list(map(int, input().split()))
(*P,) = list(map(int, input().split()))
l = set([i for i in range(-200, 200)]) - set(P)
m = 100000000
ans = 0
for i in l:
    if abs(i - X) < m:
        ans = i
        m = abs(i - X)
print(ans)

X, N = list(map(int, input().split()))
(*P,) = list(map(int, input().split()))
l = set(range(-200, 200)) - set(P)
m = 10**7
ans = 0
for i in l:
    if abs(i - X) < m:
        ans = i
        m = abs(i - X)
print(ans)

-l = set([i for i in range(-200, 200)]) - set(P) -m = 100000000 +l = set(range(-200, 200)) - set(P) +m = 10**7