fact :: Int -> Int
fact 1 = 1
fact n = n * fact (n - 1) `mod` 1000000007

solve :: Int -> Int -> Int
solve n m
  | n == m = (fact n * fact m * 2) `mod` 1000000007
  | abs (n - m) == 1 = (fact n * fact m) `mod` 1000000007
  | otherwise = 0

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