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

solve :: Int -> Int -> Int
solve n m
    |1 < abs (n - m) = 0
    |n == m = ((f n) * (f m) * 2) `mod` 1000000007
    |abs (n - m) == 1 = ((f n) * (f m)) `mod` 1000000007
    where
        f k = foldr1(\x y -> (x * y)`mod` 1000000007)[1..k]
