m = int(input())
n = int(input())
s = []
for i in range(m, n+1):
cnt = 0
if(i == 1):
continue
for j in range(2, i+1):
if(i % j == 0):
cnt += 1
if (cnt == 1):
s.append(i)
if len(s) > 0:
print(sum(s))
print(min(s))
else:
print(-1)