program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,m
    integer(int64),parameter:: md=10**9+7

    read*, n,m

    if (abs(n-m) >= 2) then
        print'(i0)', 0
    else if (n == m) then
        print'(i0)', mod(fact(n)*fact(n)*2,md)
    else
        print'(i0)', mod(fact(n)*fact(m),md)
    end if

contains
function fact(x) result(ret)
    integer(int64)::x,ret,i

    ret=1
    do i=2,x
        ret=mod(ret*i,md)
    end do
end function
end program name