program reconciled
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: n, m, i, x = 1_8
  read(*,*) n, m
  if (abs(n-m) > 1_8) then
    write(*,'(i0)') 0
  else
    if (n == m) x = 2_8
    do i = 1_8, min(n,m)
      x = mod(mod(i*i,md)*x,md)
    end do
    do i = min(n,m)+1_8, max(n,m)
      x = mod(i*x,md)
    end do
    write(*,'(i0)') x
  end if
end program reconciled