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


if len(y) == 1:
	print y[0]
elif len(z) == 1:
	print z[0]
elif 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)) 
