import scala.io.StdIn
import scala.collection.mutable.Buffer
import scala.annotation.tailrec

object Main extends App {
  val mod = 1000000007L
  val Array(n, m) = StdIn.readLine.split(" ").map(_.toLong)

  def factorial(num:Long):Long = {
    @tailrec
    def rec(acc:Long, num:Long):Long = {
      if(num == 1L) acc
      else rec(acc * num % mod, num-1L)
    }
    rec(1L,num)
  }

  val ans = if(n > m+1 || m > n+1) 0L
    else if (n == m) {
      // println(factorial(n) + " " + factorial(m))
      factorial(n) * factorial(m) * 2L % mod
    }
    else {
      factorial(n) * factorial(m) % mod
    }

  println(ans)
}