fun main(args : Array<String>) {
    var (N,M)= ReadInts()
    if((N-M)*(N-M)>1){
        println(0)
        return
    }
    var mod = 1000000007
    var ans:Long=1
    for(i in 1..N){
        ans = (ans * i) % mod 
    }
    for(i in 1..M){
        ans = (ans * i) % mod 
    }
    if(N==M){
        ans *=2
    }
    println(ans % mod)



}



fun ReadInts():MutableList<Int>{
    return readLine()!!.split(" ").map{it.toInt()}.toMutableList()
}

fun ReadLongs():MutableList<Long>{
    return readLine()!!.split(" ").map{it.toLong()}.toMutableList()
}
fun ReadDoubles():MutableList<Double>{
    return readLine()!!.split(" ").map{it.toDouble()}.toMutableList()
}
fun input() : String{
    return readLine()!!

}