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

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



ls = [0]*(102)

for p in P:

    ls[p] = 1

# xとのさがi

for i in range(101):

    L, R = X-i, X+i

    if ls[L] == 0:

        print(L)

        break



    if ls[R] == 0:

        print(R)

        break

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

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



line = [0]*(102)

for p in Ps:

    line[p] = 1



for i in range(101):

    L, R = x-i, x+i

    if line[L] == 0:

        print(L)

        break

    if line[R] == 0:

        print(R)

        break

X, n = list(map(int, input().split()))
P = list(map(int, input().split()))
ls = [0] * (102)
for p in P:
    ls[p] = 1
# xとのさがi
for i in range(101):
    L, R = X - i, X + i
    if ls[L] == 0:
        print(L)
        break
    if ls[R] == 0:
        print(R)
        break

x, n = list(map(int, input().split()))
Ps = list(map(int, input().split()))
line = [0] * (102)
for p in Ps:
    line[p] = 1
for i in range(101):
    L, R = x - i, x + i
    if line[L] == 0:
        print(L)
        break
    if line[R] == 0:
        print(R)
        break

-X, n = list(map(int, input().split())) -P = list(map(int, input().split())) -ls = [0] * (102) -for p in P: -    ls[p] = 1 -# xとのさがi +x, n = list(map(int, input().split())) +Ps = list(map(int, input().split())) +line = [0] * (102) +for p in Ps: +    line[p] = 1 -    L, R = X - i, X + i -    if ls[L] == 0: +    L, R = x - i, x + i +    if line[L] == 0: -    if ls[R] == 0: +    if line[R] == 0: