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