a=input()
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
minb=min(b)
minc=min(c)
if(minb==minc):
    print(minb)
else:
    print(min(minb,minc),end='')
    print(max(minb,minc))