
main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine
    print $
        if n == m then (2 * (fact n ^ 2)) `mod` num
        else if n == m + 1 then ((fact n ^ 2) * m) `mod` num
        else if m == n + 1 then ((fact m ^ 2) * n) `mod` num
        else 0

num :: Integer
num = 10 ^ 9 + 7

fact :: Integer -> Integer
fact 0 = 1
fact n = n * fact (n - 1)
