program OE1I
    implicit none
    integer(8)::N,M,i
    integer(8)::result=1

    read(5,*)N,M

    if(abs(N-M)>1)then
        print'(i0)',0
    else
        do i=1,N
            result=result*i
            if(result>1000000007)then
                result=mod(result,1000000007)
            end if
        end do

        do i=1,M
            result=result*i
            if(result>1000000007)then
                result=mod(result,1000000007)
            end if
        end do

        if(N==M)then
            result=result*2
        end if

        result=mod(result,1000000007)

        print'(i0)',result
    end if

end program OE1I