main :: IO ()
main = do
  xs <- (map read . words) <$> getLine
  print $ solve (xs!!0) (xs!!1)

limit :: Int
limit = 10^9 + 7

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

iter :: Int -> Int -> Int
iter 1 a = a
iter i a = iter (i-1) (mod (a * i) limit)
