a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
if min(b)<min(c) and min(b)!=min(c) :
    print(min(b)*10+min(c))
elif min(b)>min(c) and min(b)!=min(c) :
    print(min(c)*10+min(b))
elif min(b)==min(c):
    print(min(c))