from math import factorial



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

if abs(N-M) >= 2:

    print((0))

elif abs(N-M) == 1:

    print(((factorial(N)*factorial(M)) % (10**9+7)))

elif abs(N-M) == 0:

    print(((factorial(N)*factorial(M)*2) % (10**9+7)))
N, M = list(map(int, input().split()))

ans = 0



def fac(n):

    ans = 1

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

        ans *= i

        ans %= (10**9+7)

    return ans



if abs(N-M) >= 2:

    ans = 0

else:

    if N == M:

        ans = fac(N) * fac(M) * 2 % (10**9+7)

    else:

        ans = fac(N) * fac(M) % (10**9 + 7)



print(ans)
from math import factorial

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

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


def fac(n):
    ans = 1
    for i in range(1, n + 1):
        ans *= i
        ans %= 10**9 + 7
    return ans


if abs(N - M) >= 2:
    ans = 0
else:
    if N == M:
        ans = fac(N) * fac(M) * 2 % (10**9 + 7)
    else:
        ans = fac(N) * fac(M) % (10**9 + 7)
print(ans)

-from math import factorial +N, M = list(map(int, input().split())) +ans = 0 -N, M = list(map(int, input().split())) + +def fac(n): +    ans = 1 +    for i in range(1, n + 1): +        ans *= i +        ans %= 10**9 + 7 +    return ans + + -    print((0)) -elif abs(N - M) == 1: -    print(((factorial(N) * factorial(M)) % (10**9 + 7))) -elif abs(N - M) == 0: -    print(((factorial(N) * factorial(M) * 2) % (10**9 + 7))) +    ans = 0 +else: +    if N == M: +        ans = fac(N) * fac(M) * 2 % (10**9 + 7) +    else: +        ans = fac(N) * fac(M) % (10**9 + 7) +print(ans)