lst = list(map(int, input().split()))
n = min(lst)
while 1:
count = 0
for i in lst:
if n % i == 0:
count += 1
if count > 2:
break
n += 1
print(n)
lst = list(map(int, input().split()))
n = min(lst)
while 1:
count = 0
for i in lst:
if n % i == 0:
count += 1
if count > 2:
break
n += 1
print(n)