INF = int(1e9 + 7)





def modmulti(a, b):

    # aとbを掛けた値をmodする(a * b mod p)

    return a * b % INF





def factorial(x):

    FCT = 1

    for i in range(2, x + 1):

        FCT = modmulti(i, FCT)

    return FCT





def main():

    N, M = list(map(int, input().split()))

    MIN_NM = factorial(min(N, M))

    if N == M:

        print((modmulti(2, modmulti(MIN_NM, MIN_NM))))

    elif abs(N - M) <= 1:

        print((modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))

    else:

        print((0))



    return





main()

INF = int(1e9 + 7)





def factorial(x):

    FCT = 1

    for i in range(2, x + 1):

        FCT = i * FCT % INF

    return FCT





def main():

    N, M = list(map(int, input().split()))

    MIN_NM = factorial(min(N, M))

    if N == M:

        print((2 * MIN_NM * MIN_NM % INF))

    elif abs(N - M) <= 1:

        print((MIN_NM * MIN_NM * max(N, M) % INF))

    else:

        print((0))



    return





main()

INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = modmulti(i, FCT)
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M:
        print((modmulti(2, modmulti(MIN_NM, MIN_NM))))
    elif abs(N - M) <= 1:
        print((modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))
    else:
        print((0))
    return


main()

INF = int(1e9 + 7)


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = i * FCT % INF
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M:
        print((2 * MIN_NM * MIN_NM % INF))
    elif abs(N - M) <= 1:
        print((MIN_NM * MIN_NM * max(N, M) % INF))
    else:
        print((0))
    return


main()

- - -def modmulti(a, b): -    # aとbを掛けた値をmodする(a * b mod p) -    return a * b % INF -        FCT = modmulti(i, FCT) +        FCT = i * FCT % INF -        print((modmulti(2, modmulti(MIN_NM, MIN_NM)))) +        print((2 * MIN_NM * MIN_NM % INF)) -        print((modmulti(MIN_NM, modmulti(MIN_NM, max(N, M))))) +        print((MIN_NM * MIN_NM * max(N, M) % INF))