import Data.List
divisor :: Int
divisor = 1000000007
solve :: Int -> Int -> Int
solve n m =
    case abs (n-m) of
         0 -> 2 *: (factMod n) *: (factMod m)
         1 -> (factMod n) *: (factMod m)
         _ -> 0

(*:) :: Int -> Int -> Int
(*:) x y = (x*y) `mod` divisor

factMod :: Int -> Int
factMod n = foldl1' (*:) [n, n-1..1]

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