import scala.io.StdIn._

object Main extends App {

  val Array(n,m) = readLine().split(" ").map(_.toInt)

  val mod = (1e9 + 7).toInt
  def solve() = {
    val diff = (n-m).abs
    val ans = if(diff > 1) 0L
    else if(diff > 0) {
      val larger = Math.max(n,m)
      val fact = factorial(larger-1)
      larger * fact % mod * fact
    } else {
      val fact = factorial(n)
      2 * fact % mod * fact
    }
    ans % mod
  }

  def factorial(num: Long): Long = {
    var i = 1
    var ans = 1L
    while(i <= num) {
      ans *= i
      ans %= mod
      i += 1
    }
    ans
  }

  println(solve())

}

