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

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

fact n
  | n == 0 = 1
  | otherwise =  mod (n * fact (n-1)) q