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

y.sort()
z.sort()

if y[0] == z[0]:
	print y[0]
else:
	print str(y[0]) + str(z[0])


