main = do
  (n:m:_) <- getLine >>= return . (map read) . words :: IO [Integer]
  print $ f n m

  where
    f n m
      | abs (n-m) >= 2 = 0
      | n == m = (2 * (g n) * (g m)) `mod` (10^9+7)
      | otherwise = ((g n) * (g m)) `mod` (10^9+7)

    g 0 = 1
    g n = (n * (g (n-1))) `mod` (10^9+7)
