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

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

 

ans = X

for i in range(101):

    a = X + i

    b = X - i

    if a not in P:

        ans = a

        if b not in P:

            ans = b

        break

    if b not in P:

        ans = b

        break

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

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

 

ans = X

for i in range(N+1):

    a = X + i

    b = X - i

    if a not in P:

        ans = a

        if b not in P:

            ans = b

        break

    if b not in P:

        ans = b

        break

print(ans)
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
ans = X
for i in range(101):
    a = X + i
    b = X - i
    if a not in P:
        ans = a
        if b not in P:
            ans = b
        break
    if b not in P:
        ans = b
        break
print(ans)

X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
ans = X
for i in range(N + 1):
    a = X + i
    b = X - i
    if a not in P:
        ans = a
        if b not in P:
            ans = b
        break
    if b not in P:
        ans = b
        break
print(ans)

-for i in range(101): +for i in range(N + 1):