import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()

  val mod = 1_000_000_000 + 7L

  if (Math.abs(n - m) > 1) {
    println(0)
    return
  }

  var nc = 1L
  for (i in 1..n) {
    nc = nc * i.toLong() % mod
  }
  var mc = 1L
  for (i in 1..m) {
    mc = mc * i.toLong() % mod
  }

  var ans = nc * mc % mod

  if (n == m) {
    ans = ans * 2 % mod
  }

  println(ans)

}
