import Data.List

main = interact $ show . sol . map read . words

sol [n,m] = if abs (n-m) > 1 then 0 
  else f @*@ f @*@ if n==m then 2 else max n m
  where
  f = foldl1' (@*@) [1..min n m]

infixl 7 @*@
(@*@) a b = a*b `mod` (10^9+7) :: Int