{-# LANGUAGE CPP #-}

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

#define MOD 1000000007

modFact :: Int -> Int
modFact 0 = 1
modFact 1 = 1
modFact n = n * modFact (n - 1) `mod` MOD

main :: IO ()
main = do
    [n, m] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ case abs (n - m) of
                0 -> modFact n * modFact m * 2 `mod` MOD
                1 -> modFact n * modFact m `mod` MOD
                _ -> 0
