https://www.acmicpc.net/problem/2581
m=int(input())
n=int(input())
min=10000
sum=0
count=0
for i in range(m,n+1):
if i==1:
count=1
for j in range(2,i):
if(i%j==0):
count=1
if count==0:
sum+=i
if i<min:
min=i
count=0
if sum==0:
print("-1")
else:
print(sum)
print(min)