fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val diff = Math.abs(n - m)
    if (diff >= 2) {
        println(0)
        return
    }
    val key = (Math.pow(10.0, 9.0) + 7).toLong()
    var pN = 1L
    var pM = 1L

    for (i in n downTo 2) {
        pN = (pN * i) % key
    }
    for (i in m downTo 2) {
        pM = (pM * i) % key
    }

    val result = if (diff == 1) {
        (pN * pM) % key
    } else {
        (((pN * pM) % key) * 2) % key
    }
    println(result)
}