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

ans :: Integer -> Integer -> Integer
ans n m
  | abs (n - m) >= 2 = 0
  | n == m = mod' (f n * f n * 2)
  | otherwise = mod' (f n * f m)

f :: Integer -> Integer
f n
  | n == 0 = 1
  | otherwise = mod' (n * mod' (f (n - 1)))

mod' :: Integer -> Integer
mod' n = n `mod` 1000000007
