awk -M '\
function gcd(a, b, tmp)
{
    if(a<b){tmp=a;a=b;b=tmp}
    if(b == 0)return a;
    return gcd(b, a%b);
}
function lcm(a, b)
{
    return a * b / gcd(a, b);
}
{
    X=$1; Y=$2
    if(X%Y==0){
        print -1;
        exit
    }
    if(X<Y){
        print X;
        exit
    }
    print lcm(X,Y)-X
}'