let permutation ( * ) n =
  Array.fold_left ( * ) 1 @@ Array.init n @@ fun i -> i + 1

let modulo = 1000000007

let ( *^ ) m n = ((m mod modulo) * (n mod modulo)) mod modulo

(* If N = M :
  DMDM
  MDMD
  If N = M + 1 :
  DMDMD
  if N = M - 1 :
  MDMDM
  otherwise :
  impossible *)
let () = Printf.printf "%d\n" @@ Scanf.scanf "%d %d" (fun n m ->
  if n = m then
    let perm = permutation ( *^ ) n in
    2 *^ perm *^ perm
  else if n = m + 1 then
    let perm = permutation ( *^ ) m in
    n *^ perm *^ perm
  else if n = m - 1 then
    let perm = permutation ( *^ ) n in
    m *^ perm *^ perm
  else 0)