q = 10^9+7

main = do
 [n,m] <- map read . words <$> getLine
 print (reconciled n m)

reconciled n m
 | abs (n-m) > 1 = 0
 | n == m = mod (fact n * fact m * 2 ) q
 | otherwise = mod (fact n * fact m) q

fact n = foldr (\x acc -> mod (x*acc) q) 1 [1..n]