import sys

from math import factorial





sys.setrecursionlimit(500000)

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

MOD = 10**9 + 7

diff = abs(N - M)





if diff == 0:

    ans = (factorial(N) * factorial(M)) * 2

elif diff == 1:

    ans = factorial(N) * factorial(M)

else:

    ans = 0





ans %= MOD

print(ans)
def fact(n):

    ret = 1

    MOD = 10**9 + 7

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

        ret = ret * i % MOD

    return ret





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

MOD = 10**9 + 7

diff = abs(N - M)





if diff == 0:

    ans = (fact(N) * fact(M)) * 2

elif diff == 1:

    ans = fact(N) * fact(M)

else:

    ans = 0





ans %= MOD

print(ans)
import sys
from math import factorial

sys.setrecursionlimit(500000)
N, M = list(map(int, input().split()))
MOD = 10**9 + 7
diff = abs(N - M)
if diff == 0:
    ans = (factorial(N) * factorial(M)) * 2
elif diff == 1:
    ans = factorial(N) * factorial(M)
else:
    ans = 0
ans %= MOD
print(ans)

def fact(n):
    ret = 1
    MOD = 10**9 + 7
    for i in range(1, n + 1):
        ret = ret * i % MOD
    return ret


N, M = list(map(int, input().split()))
MOD = 10**9 + 7
diff = abs(N - M)
if diff == 0:
    ans = (fact(N) * fact(M)) * 2
elif diff == 1:
    ans = fact(N) * fact(M)
else:
    ans = 0
ans %= MOD
print(ans)

-import sys -from math import factorial +def fact(n): +    ret = 1 +    MOD = 10**9 + 7 +    for i in range(1, n + 1): +        ret = ret * i % MOD +    return ret -sys.setrecursionlimit(500000) + -    ans = (factorial(N) * factorial(M)) * 2 +    ans = (fact(N) * fact(M)) * 2 -    ans = factorial(N) * factorial(M) +    ans = fact(N) * fact(M)