import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.Array

modNum :: Int
modNum = 10^9 + 7

solve :: Int -> Int -> Int
solve n m
    | n > m = solveI n m
    | n < m = solveI m n
    | otherwise = ((solveI n m) + (solveI m n)) `mod` modNum

solveI :: Int -> Int -> Int
solveI 1 1 = 1
solveI n m
    | n - m >= 2 = 0
    | otherwise = (n * (solveI m (n - 1))) `mod` modNum

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