val MOD = 1000000007L

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }

    if (Math.abs(n-m) >= 2L) {
        println(0)
        return
    }

    if (n == m) {
        val mp = modPerm(n, n, MOD)
        println((2 * mp % MOD) * mp % MOD)
    } else {
        println(modPerm(n, n, MOD) * modPerm(m, m, MOD) % MOD)
    }
}

fun modPerm(n: Long, k: Long, m: Long): Long {
    require(n > 0 && k >= 0)
    return (n - k + 1 .. n).fold(1L) { acc, i -> (acc * i) % m }
}