"use strict";


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    // 差が2以上あると交互に並べられない
    if(Math.abs(N - M) > 1) {
        console.log(0);
        return;
    }
    
    const MOD = 1e9 + 7;
    let answer = 1;
    
    for(let i=1; i<=N; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    for(let i=1; i<=M; i++) {
        answer = (answer % MOD) * (i % MOD);
    }

    console.log(answer % MOD);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));