x, n = list(map(int, input().split()))

p = [int(y) for y in input().split()]



for i in range(200):

    if x-i not in p:

        print((x-i))

        break

    if x+i not in p:

        print((x+i))

        break
x, n = list(map(int, input().split()))

p = {int(i) for i in input().split()}

 

for i in range(55):

    if x-i not in p:

        print((x-i))

        break

    if x+i not in p:

        print((x+i))

        break
x, n = list(map(int, input().split()))
p = [int(y) for y in input().split()]
for i in range(200):
    if x - i not in p:
        print((x - i))
        break
    if x + i not in p:
        print((x + i))
        break

x, n = list(map(int, input().split()))
p = {int(i) for i in input().split()}
for i in range(55):
    if x - i not in p:
        print((x - i))
        break
    if x + i not in p:
        print((x + i))
        break

-p = [int(y) for y in input().split()] -for i in range(200): +p = {int(i) for i in input().split()} +for i in range(55):