modulus :: Integer
modulus = 1000000007

fact :: Integral a => a -> a
fact n = f n 1
  where
    f 0 b  = b
    f a b = b `seq` f (a - 1) (a * b)


solve :: Integer -> Integer -> Integer
solve n m
  | abs (n - m) > 1  = -1
  | abs (n - m) == 1 = fact n * fact m
  | otherwise        = 2 * fact n * fact m

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