import Data.Int (Int64)

factmod :: Integral a => a -> a -> a
factmod p n = foldr1 (\x y -> x * y `mod` p) [1 .. n] `mod` p

solve :: Integral a => a -> a -> a -> a
solve p n m
    | n > m = solve p m n
    | m - n > 1 = 0
    | m == n = 2 * f m * f n `mod` p
    | otherwise = f m * f n `mod` p
    where f = factmod p

main :: IO ()
main = do
    let p = 1000000007 :: Int64
    [n, m] <- fmap read . words <$> getLine :: IO [Int64]
    print $ solve p n m
