import java.math.BigInteger

fun main(args: Array<String>) {
    abc065c()
}

val mod = BigInteger.valueOf(1000000000L + 7L)

fun abc065c() {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }

    if (Math.abs(n - m) > 1) return println(0)

    val answer = fact(n) * fact(m) % mod * if (n == m) BigInteger.valueOf(2) else BigInteger.valueOf(1)

    println(answer % mod)
}

private fun fact(n: Long): BigInteger {
    var answer = BigInteger.ONE
    (n downTo 2).forEach {
        answer *= BigInteger.valueOf(it)
        answer %= mod
    }
    return answer
}
