import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, m] <- getIntList
    let ans | n == m = productMod [(productMod [1..n]), (productMod [1..m]), 2]
            | abs (n - m) == 1 = mulMod (productMod [1..n]) (productMod [1..m])
            | otherwise = 0
    print ans

moduloN = 10 ^ 9 + 7
modN = flip mod moduloN
mulMod x y = modN $ x * y
productMod xs = foldl' mulMod 1 xs