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

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

for i in range(105):

    if (x-i) not in a:

        print((x-i))

        break

    if (x+i) not in a:

        print((x+i))

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

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

for i in range(105):

    if (x-i) not in a:

        print((x-i))

        exit()

    if (x+i) not in a:

        print((x+i))

        exit()
x, n = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(105):
    if (x - i) not in a:
        print((x - i))
        break
    if (x + i) not in a:
        print((x + i))
        break

x, n = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(105):
    if (x - i) not in a:
        print((x - i))
        exit()
    if (x + i) not in a:
        print((x + i))
        exit()

-        break +        exit() -        break +        exit()