x = raw_input()

lista1 = [int(x[0])]
lista2 = [int(x[2])]

valores1 = raw_input().split(" ")
valores2 = raw_input().split(" ")

z = min(valores1)
y = min(valores2)

if(z<=y):
	z = z+y
else:
	z = y+z

print (int(z))