p = 1000000007

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

factorial 0 f = f
factorial n f = factorial (n - 1) (f * n `mod` p)

solve n m
  | abs(n - m) > 1  = 0
  | abs(n - m) == 1 = (factorial n 1) * (factorial m 1) `mod` p
  | otherwise = 2 * (factorial n 1) * (factorial m 1) `mod` p
