import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val m = sc.nextInt



  val res =
    if(Math.abs(n - m) >= 2) 0L
    else {
      val max = Math.max(n,m)
      val min = Math.min(n,m)

      val fact = (1L to Math.max(n,m).toLong).foldLeft(Vector.empty[Long]){case (vec, k) =>
        if(vec.isEmpty) Vector(k)
        else vec :+ vec.last * k % 1000000007L
      }

      if(max > min){
        fact(max - 1) * fact(min - 1) % 1000000007L
      }else {
        ( fact(max - 1) * fact(min - 1) % 1000000007L) * 2L % 1000000007L
      }
    }

  println(res)

}