import Control.Applicative
import Data.List
import qualified Data.Set as Set

main = do
    [n,m] <- map read . words <$> getLine
    print $ solve n m

solve :: Int -> Int -> Int
solve n m | abs (n-m) > 1 = 0
            | n' == m' = mp 2 (mp nf' nf')
            | otherwise = mp nf' mf'
            where n' = max n m
                  m' = min n m
                  nf' = mf n'
                  mf' = mf m'

mprod x y m = mod ((mod x m) * (mod y m)) m

mfact 0 _ = 1
mfact n m = mprod n (mfact (n-1) m) m

mm = 1000000007

mf n = mfact n mm
mp x y= mprod x y mm
