lens = [int(i) for i in input().split()]
s1 = [int(i) for i in input().split()]
s2 = [int(i) for i in input().split()]
if min(s1) == min(s2):
    print(min(s1))
elif min(s1) < min(s2):
    print(str(min(s1)) + str(min(s2)))
else:
    print(str(min(s2)) + str(min(s1)))
