main = do
  [n, m] <- map read . words <$> getLine
  print $ (\x -> x `mod` q) $ f n m 
    where q = 1000000007
 
f :: Integer -> Integer -> Integer
f n m
  | abs (n - m) > 1 = 0
  | abs (n - m) == 1 = (fact n) * (fact m)
  | otherwise = 2 * (fact n) * (fact m)
 
fact :: Integer -> Integer
fact n
  | n == 0 = 1
  | otherwise =  n * fact (n-1)