-- import Data.List (nub, sort)

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

-- |
-- >>> solve 2 2
-- 8
-- >>> solve 3 2
-- 12
-- >>> solve 1 8
-- 0
-- >>> solve 100000 100000
-- 530123477
solve :: Integer -> Integer -> Integer
solve n m
  | abs (n - m) >= 2 = 0
  | n == m = n' * m' * 2 `mod` base
  | otherwise = n' * m' `mod` base
  where
    n' = fact n `mod` base
    m' = fact m `mod` base

base :: (Eq a, Num a) => a
base = 10 ^ (9 :: Int) + 7

fact :: (Eq a, Num a, Integral a) => a -> a
fact 0 = 1
fact n = (n * fact (n - 1)) `mod` base

