import Control.Applicative( (<$>))
import Data.List( foldl1')
import Data.Word( Word32)

main = do
    [n_, m_] <- map read . words <$> getLine
    let
	mn = min n_ m_::Word32
	v = product' [1..mn]
	magicnumber = 1000000007
	product' = foldl1' mul 
	  where
	    mul a b = fromInteger $
			(toInteger a*toInteger b) `rem` magicnumber
    print $ if n_==m_
		then (2*(toInteger v)^2) `rem` toInteger magicnumber
		else if 1 == abs (n_ - m_)
		    then ((toInteger mn+1)*(toInteger v)^2) `rem` toInteger magicnumber
		    else 0