import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    println(problem065c(n, m))
}

fun problem065c(n: Long, m: Long): Long {
    if (Math.abs(n - m) >= 2) return 0
    val mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()
    fun computeFactorial(n: Long): Long {
        return (1..n).toList().reduce { acc, l -> acc * l % mod }
    }

    return if (n != m) {
        computeFactorial(Math.max(n, m)) * computeFactorial(Math.min(n, m)) % mod
    } else {
        computeFactorial(n) * computeFactorial(n) * 2 % mod
    }
}