import scala.io.StdIn.readLine

object Main extends App {
  val MOD = 1000000007

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

  val ans = (if(math.abs(n - m) > 1L) 0
    else {
    val d = 1L.to(n).foldLeft(1L){case (s, i) => s * i % MOD} * 1L.to(m).foldLeft(1L){case (s, i) => s * i % MOD}
    if(n == m) d * 2
    else d
  }) % MOD

  println(ans)

}