import java.util.*
import java.math.*
fun main(args: Array<String>) {

    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    if (N-M !in -1..1) {
        println(0)
        return
    }
    val mod = 1000000007
    fun factorial(n:Int,m:Int) :Long {
        var res = 1L
        for (i in 1..n) {
            res *= i
            res %= mod
        }
        for (i in 1..m) {
            res *= i
            res %= mod
        }
        return res
    }
    var ans  = factorial(N,M)
    if (N == M) ans *= 2
    println(ans%mod)
}
