x,n,*l=list(map(int,open(0).read().split()))

print((min((abs(i-x),i) for i in range(102) if i not in l)[1]))
x,_,*l=list(map(int,open(0).read().split()))

print((min((abs(i-x),i) for i in {*list(range(102))}-{*l})[1]))
x, n, *l = list(map(int, open(0).read().split()))
print((min((abs(i - x), i) for i in range(102) if i not in l)[1]))

x, _, *l = list(map(int, open(0).read().split()))
print((min((abs(i - x), i) for i in {*list(range(102))} - {*l})[1]))

-x, n, *l = list(map(int, open(0).read().split())) -print((min((abs(i - x), i) for i in range(102) if i not in l)[1])) +x, _, *l = list(map(int, open(0).read().split())) +print((min((abs(i - x), i) for i in {*list(range(102))} - {*l})[1]))