
x = list(map(int, input().split()))
a = list(map(int, input().split()))
a =a[0:x[0]]
b = list(map(int, input().split()))
b =b[0:x[1]]
A=min(a)
B=min(b)
if A==B:
    print(B)
else:
    if A>B:
        print(B*10+A)
    else: 
        print(A*10+B)
