def 解():

    iN,iM = [int(_) for _ in input().split()]

    iD = 10**9+7



    if abs(iN - iM) <= 1:

        iFacM = 1

        for i in range(1,iM+1):

            iFacM *= i

            iFacM %=iD

        if iN == iM:

            print(( iFacM * iFacM % iD * 2 % iD ))

        else:

            iFacN = 1

            for i in range(1,iN+1):

                iFacN *= i

                iFacN %=iD

            print(( iFacM * iFacN % iD  ))

    else:

        print((0))

解()

def 解():

    iN,iM = [int(_) for _ in input().split()]

    iD = 10**9+7



    if abs(iN - iM) <= 1:

        if iN < iM:

            iN,iM = iM,iN

        iFacM = 1

        for i in range(1,iM+1):

            iFacM *= i

            iFacM %=iD

        if iN == iM:

            print(( iFacM * iFacM % iD * 2 % iD ))

        else:

            iFacN = iFacM

            for i in range(iM+1,iN+1):

                iFacN *= i

                iFacN %=iD

            print(( iFacM * iFacN % iD  ))

    else:

        print((0))

解()

def 解():
    iN, iM = [int(_) for _ in input().split()]
    iD = 10**9 + 7
    if abs(iN - iM) <= 1:
        iFacM = 1
        for i in range(1, iM + 1):
            iFacM *= i
            iFacM %= iD
        if iN == iM:
            print((iFacM * iFacM % iD * 2 % iD))
        else:
            iFacN = 1
            for i in range(1, iN + 1):
                iFacN *= i
                iFacN %= iD
            print((iFacM * iFacN % iD))
    else:
        print((0))


解()

def 解():
    iN, iM = [int(_) for _ in input().split()]
    iD = 10**9 + 7
    if abs(iN - iM) <= 1:
        if iN < iM:
            iN, iM = iM, iN
        iFacM = 1
        for i in range(1, iM + 1):
            iFacM *= i
            iFacM %= iD
        if iN == iM:
            print((iFacM * iFacM % iD * 2 % iD))
        else:
            iFacN = iFacM
            for i in range(iM + 1, iN + 1):
                iFacN *= i
                iFacN %= iD
            print((iFacM * iFacN % iD))
    else:
        print((0))


解()

+        if iN < iM: +            iN, iM = iM, iN -            iFacN = 1 -            for i in range(1, iN + 1): +            iFacN = iFacM +            for i in range(iM + 1, iN + 1):