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

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

print((min([i for i in range(102) if i not in a], key=lambda y:abs(x-y))))

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

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

print((min((i for i in range(102) if i not in a), key=lambda y:abs(x-y))))

x, n = list(map(int, input().split()))
a = set(map(int, input().split()))
print((min([i for i in range(102) if i not in a], key=lambda y: abs(x - y))))

x, n = list(map(int, input().split()))
a = set(map(int, input().split()))
print((min((i for i in range(102) if i not in a), key=lambda y: abs(x - y))))

-print((min([i for i in range(102) if i not in a], key=lambda y: abs(x - y)))) +print((min((i for i in range(102) if i not in a), key=lambda y: abs(x - y))))