const [m, n] = require("fs").readFileSync(0,"utf8").toString().trim().split('\n').map(Number);
let min = 0, sum = 0;

for(let num=m; num<=n; num++) {
    if(num === 1) continue;

    let isPrime = true;
    for(let i=2; i*i<=num; i++) {
        if(num%i==0) {
            isPrime = false;
            break;
        }
    }

    if(isPrime) {
        if(min==0) {
            min = num;
        }
        sum += num;
    }
}

if(sum===0) console.log(-1);
else { 
    console.log(sum);
    console.log(min);
}