local a, b = io.read("*n", "*n")
if(1 < math.abs(a - b)) then print(0)
else
  local min = math.min(a, b)
  local ret = 1
  local mod = 1000000007
  for i = 2, min do
    ret = (ret * i) % mod
  end
  ret = (ret * ret) % mod
  if(a == b) then
    ret = (ret * 2) % mod
  else
    ret = (ret * (min + 1)) % mod
  end
  print(ret)
end
