import Prelude

cut = 1000000007

factorial :: Int->Int
factorial 0 = 1
factorial n = n `seq` (n*factorial (n-1) `mod` cut)

inusaru :: Int->Int->Int
inusaru a b 	|a==b = (2*(factorial a)*(factorial b)) `mod` cut
		|(a-b)==1 = ( (factorial a)*(factorial b)) `mod` cut
		|(b-a)==1 = ( (factorial a)*(factorial b)) `mod` cut
		|otherwise = 0


main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b] <- map read . words <$> getLine
    putStrLn $ show $ inusaru a b

