import           Control.Monad
import qualified Data.ByteString.Char8       as BS
import           Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VM

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

main = do
  [n, m] <- getIntList

  let (x, y) = if n >= m then (n, m) else (m, n)
      p = 10^9 + 7 :: Int

  d <- VM.new (x+1)
  VM.set d (0::Int)

  let fac :: Int -> IO Int
      fac x | x == 1    = return 1
            | otherwise = do
                t <- VM.read d x
                if t > 0
                  then return t
                  else do fx_1 <- fac (x-1)
                          let r = x * fx_1 `mod` p
                          VM.write d x r
                          return r

      solve :: Int -> Int -> IO Int
      solve a b | a - b >= 2 = return 0
                | a - b == 1 = do fa <- fac a
                                  fb <- fac b
                                  return $ fa * fb `mod` p
                | otherwise  = do -- a == b
                    fa <- fac a
                    return $ fa * fa `mod` p * 2 `mod` p

  ans <- solve x y
  print ans