m,n=map(int,raw_input().split(" "))
s1=min(map(int,raw_input().split(" ")))
s2=min(map(int,raw_input().split(" ")))
if(s1==s2):
        print s1
elif(s1>s2):
        print s2*10+s1
else:
        print s1*10+s2        