val primes1 = intArrayOf(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313)
fun main(args: Array<String>) {
    val s = readLine()!!
    val (n, m) = s.split(" ").map(String::toInt)
    val divider = 1000000000L + 7L


    val primes = primes1

    fun factorial_product(n: Int, m: Int): Long {
        val counts = IntArray(primes.size, { 0 })
        val restPrimes: MutableList<Int> = mutableListOf()

        val min = Math.min(n, m)
        val max = Math.max(n, m)

        for (i in 1..min) {
            var dividend = i
            for (index in 0 until primes.size) {
                while (dividend % primes[index] == 0) {
                    dividend /= primes[index]
                    counts[index] += 2
                }
            }
            restPrimes.add(dividend)
            restPrimes.add(dividend)
        }
        for (i in min + 1 .. max) {
            var dividend = i
            for (index in 0 until primes.size) {
                while (dividend % primes[index] == 0) {
                    dividend /= primes[index]
                    counts[index] += 1
                }
            }
        }

        var result: Long = 1L

        for (index in 0 until primes.size) {
            repeat(counts[index]) { result = result * primes[index] % divider}
        }
        for (prime in restPrimes) {
            result = result * prime % divider
        }

        return result
    }

    val result = when {
        n == m -> factorial_product(n, n) * 2L % divider
        n + 1 == m || m + 1 == n -> factorial_product(n, m)
        else -> 0L
    }

    println(result)
}
