main :: IO ()
main = do
    str <- getContents
    let n:m:_ = map read $ words str
    putStrLn $ show $ solveC n m

solveC :: Int -> Int -> Int
solveC n m = factor (n - m) *% modfrac n *% modfrac m
    where factor 0 = 2
          factor 1 = 1
          factor (-1) = 1
          factor _ = 0

(?%) :: Integral a => (a -> a -> a) -> a -> (a -> a -> a)
(?%) f m = \a b -> (f a b `mod` m)
(*%) :: Int -> Int -> Int
(*%) = (*) ?% modnumber
(+%) :: Int -> Int -> Int
(+%) = (+) ?% modnumber
modfrac :: Int -> Int
modfrac n = foldr (*%) 1 [1..n]
modnumber :: Int
modnumber = 10^9 + 7