let id x = x

let (n,m) = Scanf.scanf "%d %d" (fun a b -> (a,b))
  
let rec fact x acc =
  if x = 0 then acc else
    if x * acc > 1000000007 then fact (x-1) ((x*acc) mod 1000000007)
      else fact (x-1) (x*acc)

let ans' = if abs (n-m) > 1 then 0 else
    if n = m then (fact n 1) * (fact n 1) * 2
    else (fact (max n m) 1) * (fact (min n m) 1)

let ans = ans' mod (1000000007)
  
let () =
  Printf.printf "%d\n" ans