'use strict'

function main(input) {
  input = input.split(' ').map(v => ~~v)
  const n = input[0]
  const m = input[1]

  //交互に並べられない
  if (Math.abs(n - m) >= 2) {
    console.log(0)
    return
  }

  let nn = 1
  for (let i = 2; i <= n; i++) {
    nn *= i
  }
  let mm = 1
  for (let i = 2; i <= m; i++) {
    mm *= i
  }
  // console.log(nn,mm)

  let tmp = nn * mm
  if (n == m) {
    tmp = 2 * tmp
  }
  const ans = tmp % (Math.pow(10, 9) + 7)

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))