input()
a = [int (i) for i in input().split()]
b = [int (i) for i in input().split()]

aa = min(a)
bb = min(b)

if aa < bb:
    print(str(aa) + str(bb))
elif bb < aa:
    print(str(bb) + str(aa))
else:
    print(aa)
