object C extends App {
  val MASK = 1000000000L + 7L
  def fact(n: Long): Long = {
    var result = 1L
    for (i <- 2 to n.toInt) result = mul(result, i.toLong)
    result
  }

  def mul(x: Long, y: Long): Long = (x * y) % MASK
  def pow2(x: Long): Long = mul(x, x)

  def solve(n: Long, m: Long): Long = (n - m).abs match {
    case 0 => mul(2, pow2(fact(n)))
    case 1 => mul(pow2(fact(n min m)), (n max m))
    case _ => 0
  }

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val m = sc.nextInt()
  println(solve(n, m))
}