import io.StdIn.readLine
object Main extends App {
  val Array(d, m) = readLine.split(" ").map(_.toInt)

  println(solve(d, m))

  def solve(d: Int, m: Int) = {
    if ((d - m).abs >= 2) 0
    else {
      val ans = factorial(d, 1) * factorial(m, 1) % 1000000007
      if (d == m) (2 * ans % 1000000007) else ans
    }
  }

  def factorial(n: Int, res: Long): Long = {
    if (n <= 0) -1
    else if (n == 1) res
    else {
      factorial(n - 1, res * n % 1000000007)
    }
  }
}
