let n, m =
  let l =
    (stdin.ReadLine ()).Split(' ') |> Array.map int64
  l.[0], l.[1]

let P = 1000000007L

let ans =
  match abs (n - m) with
  | a when a > 1L -> 0L
  | 0L ->
    [1L .. n]
    |> List.fold (fun acc i -> (acc * i) % P) 1L
    |> (fun x -> 2L * (x * x) % P)
  | 1L ->
    let dogs =
      [1L .. n]
      |> List.fold (fun acc i -> (acc * i) % P) 1L
    let monkeys =
      [1L .. m]
      |> List.fold (fun acc i -> (acc * i) % P) 1L
    (dogs * monkeys) % P

ans |> stdout.WriteLine