fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toLong() }
    when (N - M) {
        0L -> println(factorial(N) * factorial(M) * 2 % mod)
        1L, -1L -> println(factorial(N) * factorial(M) % mod)
        else -> println(0)
    }
}

val mod = 1000000007

fun factorial(n: Long): Long = if (n == 1L) 1 else n * factorial(n - 1) % mod