mulMod a b = (a * b) `rem` (10^9+7)

prod 1 = 1
prod n = mulMod n (prod (n-1))

solve n m
    | (abs $ n - m) > 1 = 0
    | (abs $ n - m) == 1 = mulMod (prod n) (prod m)
    | otherwise = mulMod 2 (mulMod (prod n) (prod m))

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