program main
	implicit none
	integer    :: N, M
	integer(8) :: monkey, dog, i
	read(*, *) N, M
	if(abs(N-M) > 1) then
		write(*, *) 0
	else if(M /= N) then
		dog = 1
		do i = N, 1, -1
			dog = mod(dog*i,1000000007)
		end do
		
		monkey = 1
		do i = M, 1, -1
			monkey = mod(monkey*i,1000000007)
		end do
		
		write(*, *) mod(dog*monkey,1000000007)
	else
		dog = 1
		do i = N, 1, -1
			dog = mod(dog*i,1000000007)
		end do
		
		write(*, *) mod(2*dog*dog,1000000007)
	end if
end program main