from math import factorial

MOD = 10**9 + 7

n, m = list(map(int, input().split()))

if n == m:

    print((2 * factorial(n)**2 % MOD))

elif n - 1 == m:

    print((n * factorial(m)**2 % MOD))

elif n == m - 1:

    print((m * factorial(n)**2 % MOD))

else:

    print((0))
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()))

MOD = 10**9 + 7

if n == m:

    print((2 * factorial(n) ** 2 % MOD))

elif abs(n - m) == 1:

    print((factorial(min(m, n)) ** 2 * max(m, n) % MOD))

else:

    print((0))
from math import factorial

MOD = 10**9 + 7
n, m = list(map(int, input().split()))
if n == m:
    print((2 * factorial(n) ** 2 % MOD))
elif n - 1 == m:
    print((n * factorial(m) ** 2 % MOD))
elif n == m - 1:
    print((m * factorial(n) ** 2 % MOD))
else:
    print((0))

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()))
MOD = 10**9 + 7
if n == m:
    print((2 * factorial(n) ** 2 % MOD))
elif abs(n - m) == 1:
    print((factorial(min(m, n)) ** 2 * max(m, n) % MOD))
else:
    print((0))

-from math import factorial +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())) -n, m = list(map(int, input().split())) -elif n - 1 == m: -    print((n * factorial(m) ** 2 % MOD)) -elif n == m - 1: -    print((m * factorial(n) ** 2 % MOD)) +elif abs(n - m) == 1: +    print((factorial(min(m, n)) ** 2 * max(m, n) % MOD))