function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var dogs = parseInt(line[0]);
    var monks = parseInt(line[1]);
    var ans = 0;
    var dogsCount = 1;
    var monksCount = 1;
    var limit = 1E9+7;
    if(Math.abs(dogs-monks)>1){
        console.log(ans);
    } else {
        for(var i = 0; i<dogs; i++){
            dogsCount *= i+1;
            if(dogsCount>=limit){
                dogsCount %= limit;
            }
        }
        
//        console.log(dogsCount);
        ans = dogsCount;

        for(var i = 0; i<monks; i++){
            ans *= i+1;
            if(ans>=limit){
                ans %= limit;
            }
 //           console.log(i+" "+ans);
        }
        
        if(dogs===monks){
            ans*=2;
        }
        
        if(ans>=limit){
            ans %= limit;
        }
        
        console.log(ans);
//        console.log(dogsCount*dogsCount*2%limit);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));