x = map(int, raw_input().split())
y = map(int, raw_input().split())
z = map(int, raw_input().split())

if str(min(y)) > str(min(z)):
	print str(min(z)) + str(min(y))
elif str(min(y)) < str(min(z)):
	print str(min(y)) + str(min(z))
else:
	print str(min(y)) 
