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

mod = 10 ** 9 + 7



if abs(N - M) >1:

    print((0))

elif N == M:

    n = 1

    m = 1

    for i in range(N):

        n = n * (i + 1) % mod

    for i in range(M):

        m = m * (i + 1) % mod

    print((2 * m * n % mod))

else:

    n = 1

    m = 1

    for i in range(N):

        n = n * (i + 1) % mod

    for i in range(M):

        m = m * (i + 1) % mod

    print((m * n % mod))
N , M = list(map(int, input().split()))

mod = 10 ** 9 + 7





def factorial(n):

    ans = 1

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

        ans = ans * i % mod

    return ans





if abs(N - M) >1:

    print((0))

elif N == M:

    print((2 * factorial(N) ** 2 % mod))

else:

    print((factorial(min(M, N)) ** 2 * max(M, N) % mod))
N, M = list(map(int, input().split()))
mod = 10**9 + 7
if abs(N - M) > 1:
    print((0))
elif N == M:
    n = 1
    m = 1
    for i in range(N):
        n = n * (i + 1) % mod
    for i in range(M):
        m = m * (i + 1) % mod
    print((2 * m * n % mod))
else:
    n = 1
    m = 1
    for i in range(N):
        n = n * (i + 1) % mod
    for i in range(M):
        m = m * (i + 1) % mod
    print((m * n % mod))

N, M = list(map(int, input().split()))
mod = 10**9 + 7


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


if abs(N - M) > 1:
    print((0))
elif N == M:
    print((2 * factorial(N) ** 2 % mod))
else:
    print((factorial(min(M, N)) ** 2 * max(M, N) % mod))

+ + +def factorial(n): +    ans = 1 +    for i in range(2, n + 1): +        ans = ans * i % mod +    return ans + + -    n = 1 -    m = 1 -    for i in range(N): -        n = n * (i + 1) % mod -    for i in range(M): -        m = m * (i + 1) % mod -    print((2 * m * n % mod)) +    print((2 * factorial(N) ** 2 % mod)) -    n = 1 -    m = 1 -    for i in range(N): -        n = n * (i + 1) % mod -    for i in range(M): -        m = m * (i + 1) % mod -    print((m * n % mod)) +    print((factorial(min(M, N)) ** 2 * max(M, N) % mod))