def ten(n1, n2):
    multiplication = 0
    if spisok.index(n1) == 0:
        multiplication += max(int(n1[0]), int(n2[1]))
    else:
        if n2 == 0:
            multiplication += int(n1[0])
        else:
            multiplication += max(int(n1[0]), int(n2[1]))
    return str(multiplication)
a = input()
b = input()
summ = ''
multiplication = ''
spisok = []
if int(a) < 10 and int(b) > 10:
    c = max(int(a), int(b[-1]))
    b.replace(b[-1], str(c))
    summ=b
    for i in b:
        if i > a:
            b.replace(i, a)
    multiplication = b
elif int(a) > 10 and int(b) < 10:
    c = max(int(a[-1]), int(b))
    a.replace(a[-1], str(c))
    summ = a
    for i in a:
        if i > b:
            a.replace(i, b)
    multiplication = a
if int(a) < 10 and int(b) < 10:
    sum = max(int(a), int(b))
    multiplication = min(int(a), int(b))
    if len(a) >= len(b):
        new_b = '0' * (len(a) - len(b)) + b
        for i in range(len(b)):
            summ += str(max(a[i], new_b[i]))
        for i in b:
            number = ''
            for j in range(len(a)):
                number += str(min(int(i), int(a[j])))
            spisok.append(number)
        multiplication += spisok[0][-1]
        for i in spisok:
            index = spisok.index(i)
            if index == len(spisok) - 1:
                multiplication += ten(i, 0)
            else:
                multiplication += ten(i, spisok[index + 1])
print(summ)
print(multiplication)