import java.util.*

open class MainKt {
    companion object Static {
        @JvmStatic fun main(args: Array<String> = arrayOf()) {
            MainKt().solve()
        }
    }

    val scanner = Scanner(System.`in`)

    fun printf(pattern: String, vararg args: Any): Unit {
        println(String.format(pattern, *args))
    }

    open fun println(line: String) {
        kotlin.io.println(line)
    }

    fun println(line: Int) {
        println(line.toString())
    }

    fun println(line: Long) {
        println(line.toString())
    }

    open fun readLine(): String {
        return scanner.nextLine()
    }

    fun readArg(): String {
        return readLine()
    }

    fun readInt(): Int {
        return readArg().toInt()
    }

    fun readLong(): Long {
        return readArg().toLong()
    }

    fun readIntList(): List<Int> {
        return readArgList().map { it.toInt() }
    }

    fun readLongList(): List<Long> {
        return readArgList().map { it.toLong() }
    }

    fun readArgList(): List<String> {
        return readLine().split(" ")
    }

    fun solve() {
        val mod = Math.pow(10.0, 9.0).toLong() + 7L
        val (n, m) = readLongList()
        val d = Math.abs(n - m)
        when (d) {
            0L -> {
                var f = 1L
                for (i: Long in 1..m) {
                    f = f * i % mod
                    f = f * i % mod
                }
                f = 2 * f % mod
                println(f)
            }
            1L -> {
                var f = 1L
                for (i: Long in 1..m) {
                    f = f * i % mod
                }
                for (i in 1..n) {
                    f = f * i % mod
                }
                println(f)
            }
            else -> {
                println(0)
            }
        }
    }
}