from math import factorial



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

if n == m:

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

elif abs(n - m) < 2:

    print((factorial(n) * factorial(m) % 1000000007))

else:

    print((0))

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

mod = 10**9 + 7





def factorial(n):

    ans = 1

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

        ans *= i

        ans %= mod

    return ans

if n == m:

    ans = factorial(n)

    print((ans ** 2 * 2 % mod))

elif m - n == 1:

    ans = factorial(n)

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

else:

    print((0))

from math import factorial

n, m = list(map(int, input().split()))
if n == m:
    print((2 * factorial(n) ** 2 % 1000000007))
elif abs(n - m) < 2:
    print((factorial(n) * factorial(m) % 1000000007))
else:
    print((0))

n, m = sorted(map(int, input().split()))
mod = 10**9 + 7


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


if n == m:
    ans = factorial(n)
    print((ans**2 * 2 % mod))
elif m - n == 1:
    ans = factorial(n)
    print((ans**2 * m % mod))
else:
    print((0))

-from math import factorial +n, m = sorted(map(int, input().split())) +mod = 10**9 + 7 -n, m = list(map(int, input().split())) + +def factorial(n): +    ans = 1 +    for i in range(1, n + 1): +        ans *= i +        ans %= mod +    return ans + + -    print((2 * factorial(n) ** 2 % 1000000007)) -elif abs(n - m) < 2: -    print((factorial(n) * factorial(m) % 1000000007)) +    ans = factorial(n) +    print((ans**2 * 2 % mod)) +elif m - n == 1: +    ans = factorial(n) +    print((ans**2 * m % mod))