a=input().split()
b=input().split()
c=input().split()
for i in range(int(a[0])):
    b[i]=int(b[i])
    print(b[i])
for i in range(int(a[1])):
    c[i]=int(c[i])
if min(b)==min(c):
    print(min(b))
else:
    print(min(b)*10+min(c))
    

    
    
