import math





def main():

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

    mod = 10 ** 9 + 7

    if abs(N - M) > 1:

        ans = 0

    elif N - M == 1:

        ans = (math.factorial(M)**2 * N) % mod

    elif N - M == -1:

        ans = (math.factorial(N)**2 * M) % mod

    else:

        ans = (math.factorial(N)**2 * 2) % mod



    print(ans)





if __name__ == "__main__":

    main()

def factorial(n, mod=10**9 + 7):

    a = 1

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

        a = a * i % mod

    return a





def main():

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

    mod = 10 ** 9 + 7

    if abs(N - M) > 1:

        ans = 0

    elif abs(N - M) == 1:

        ans = (factorial(min(N, M))**2 * max(N, M)) % mod

    else:

        ans = (factorial(N)**2 * 2) % mod



    print(ans)





if __name__ == "__main__":

    main()

import math


def main():
    N, M = list(map(int, input().split()))
    mod = 10**9 + 7
    if abs(N - M) > 1:
        ans = 0
    elif N - M == 1:
        ans = (math.factorial(M) ** 2 * N) % mod
    elif N - M == -1:
        ans = (math.factorial(N) ** 2 * M) % mod
    else:
        ans = (math.factorial(N) ** 2 * 2) % mod
    print(ans)


if __name__ == "__main__":
    main()

def factorial(n, mod=10**9 + 7):
    a = 1
    for i in range(1, n + 1):
        a = a * i % mod
    return a


def main():
    N, M = list(map(int, input().split()))
    mod = 10**9 + 7
    if abs(N - M) > 1:
        ans = 0
    elif abs(N - M) == 1:
        ans = (factorial(min(N, M)) ** 2 * max(N, M)) % mod
    else:
        ans = (factorial(N) ** 2 * 2) % mod
    print(ans)


if __name__ == "__main__":
    main()

-import math +def factorial(n, mod=10**9 + 7): +    a = 1 +    for i in range(1, n + 1): +        a = a * i % mod +    return a -    elif N - M == 1: -        ans = (math.factorial(M) ** 2 * N) % mod -    elif N - M == -1: -        ans = (math.factorial(N) ** 2 * M) % mod +    elif abs(N - M) == 1: +        ans = (factorial(min(N, M)) ** 2 * max(N, M)) % mod -        ans = (math.factorial(N) ** 2 * 2) % mod +        ans = (factorial(N) ** 2 * 2) % mod