from math import factorial



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



a = 10**9+7

if abs(N-M) >= 2:

    print((0))



elif N == M:

    print(((2*factorial(N)*factorial(M)) % a))



else:

    print(((factorial(N)*factorial(M)) % a))

def factorial(n):

    ans = 1

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

        ans = ans * i % 1000000007

    return ans





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



MAD = 10**9+7

if abs(N-M) >= 2:

    print((0))



elif N == M:

    print(((2*factorial(N)*factorial(M)) % MAD))



else:

    print(((factorial(N)*factorial(M)) % MAD))

from math import factorial

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

def factorial(n):
    ans = 1
    for i in range(2, n + 1):
        ans = ans * i % 1000000007
    return ans


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

-from math import factorial +def factorial(n): +    ans = 1 +    for i in range(2, n + 1): +        ans = ans * i % 1000000007 +    return ans + -a = 10**9 + 7 +MAD = 10**9 + 7 -    print(((2 * factorial(N) * factorial(M)) % a)) +    print(((2 * factorial(N) * factorial(M)) % MAD)) -    print(((factorial(N) * factorial(M)) % a)) +    print(((factorial(N) * factorial(M)) % MAD))