import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val mod = 1_000_000_007L
    val (n, m) = readLongList()
    val nFact = calcFactorial(n, mod)
    val mFact = calcFactorial(m, mod)
    val ans = when {
        abs(n - m) >= 2 -> 0
        n == m -> (2 * ((nFact * mFact) % mod)) % mod
        else -> (nFact * mFact) % mod
    }
    out.println(ans)
}

/** O(n) mod <= 2_147_483_648 */
fun calcNPermutationM(n: Long, m: Long, MOD: Long = (1L shl 31)): Long {
    var ret = 1L
    for (i in (n - m + 1)..n) { ret = (ret * i) % MOD }
    return ret
}

/** O(x) mod <= 2_147_483_648 */
fun calcFactorial(x: Long, MOD: Long = (1L shl 31)) = calcNPermutationM(x, x, MOD)

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)
