M = int(input())
N = int(input())
check = [False for i in range(N+1)]
for i in range(2, int(N**0.6)):
if check[i] == False:
for j in range(2 * i, N + 1, i):
check[j] = True
prime_number = []
for i in range(M, N + 1):
if i >= 2:
if check[i] == False:
prime_number.append(i)
if len(prime_number) == 0:
print(-1)
else :
print(sum(prime_number))
print(min(prime_number))