import Control.Applicative( (<$>))

main = do
    [n_, m_] <- map read . words <$> getLine
    let
	mn = min n_ m_
	v = product [1..mn]
	magicnumber = 1000000007
    print $ if n_==m_
		then (2*v^2) `rem` magicnumber
		else if 1 == abs (n_ - m_)
		    then ((mn+1)*v^2) `rem` magicnumber
		    else 0