object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val mod = 1000000007L
	val swich = math.abs(n - m)
	if(swich >= 2) println(0)
	else if(swich == 1){
		println((f(n)*f(m))%mod)
	}else{
		println((2L*f(n)*f(m))%mod)
	}

	def f(x: Int): Long = Range(1, x+1).map(_ * 1L).reduce((a,b) => (a*b)%mod)
} 
