import Data.Int
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int64]
  print $ solve n m 

inf :: Int64
inf = 10^9+7

powMod :: Int64 -> Int64 -> Int64
powMod x y = (x*y) `mod` inf

prod :: Int64 -> Int64
prod 1 = 1
prod x = powMod x (prod (x-1))

solve :: Int64 -> Int64 -> Int64
solve x y
  | abs (x-y) > 1 = 0
  | even (x+y) = powMod (powMod (prod x) (prod y)) 2
  | otherwise = powMod (prod x) (prod y)