total = 0
minPrime = 0
for n in range(int(input()), int(input())+1) :
    if n==1 : continue
    isPrime = True
    for i in range(2, int(n**0.5)+1) :
        if n%i==0 :
            isPrime = False
            break

    if isPrime :
        if minPrime==0 : minPrime = n
        total += n

if total==0 : print(-1)
else :
    print(f'{total}\n{minPrime}')