M = int(input())
N = int(input())
prime_nums = list()
for num in range(M, N+1):
is_prime = True
if num == 1:
continue
for sub_num in range(2, num):
if num % sub_num == 0:
is_prime = False
break
if is_prime:
prime_nums.append(num)
if prime_nums:
print(sum(prime_nums))
print(min(prime_nums))
else:
print(-1)