import math

mod = 10**9+7

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

if n!=m and abs(n-m)!=1:

    print("0")

    exit()



if n==m:

    n=max(n,m)

    m=min(n,m)

    ans = math.factorial(n)*2*math.factorial(m)

    print((ans%mod))

else:

    ans = math.factorial(n)*math.factorial(m)

    print((ans%mod))





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

if 2<=abs(n-m):

    print((0))

    exit()

mod=10**9+7



if abs(n-m)==1:

    dog=1

    cat=1

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

        dog*=i

        dog=dog%mod

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

        cat*=i

        cat=cat%mod

    print((dog*cat%mod))

else:

    dog=1

    cat=1

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

        dog*=i

        dog=dog%mod

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

        cat*=i

        cat=cat%mod

    print((dog*cat*2%mod))



import math

mod = 10**9 + 7
n, m = list(map(int, input().split()))
if n != m and abs(n - m) != 1:
    print("0")
    exit()
if n == m:
    n = max(n, m)
    m = min(n, m)
    ans = math.factorial(n) * 2 * math.factorial(m)
    print((ans % mod))
else:
    ans = math.factorial(n) * math.factorial(m)
    print((ans % mod))

n, m = list(map(int, input().split()))
if 2 <= abs(n - m):
    print((0))
    exit()
mod = 10**9 + 7
if abs(n - m) == 1:
    dog = 1
    cat = 1
    for i in range(1, n + 1):
        dog *= i
        dog = dog % mod
    for i in range(1, m + 1):
        cat *= i
        cat = cat % mod
    print((dog * cat % mod))
else:
    dog = 1
    cat = 1
    for i in range(1, n + 1):
        dog *= i
        dog = dog % mod
    for i in range(1, m + 1):
        cat *= i
        cat = cat % mod
    print((dog * cat * 2 % mod))

-import math - +n, m = list(map(int, input().split())) +if 2 <= abs(n - m): +    print((0)) +    exit() -n, m = list(map(int, input().split())) -if n != m and abs(n - m) != 1: -    print("0") -    exit() -if n == m: -    n = max(n, m) -    m = min(n, m) -    ans = math.factorial(n) * 2 * math.factorial(m) -    print((ans % mod)) +if abs(n - m) == 1: +    dog = 1 +    cat = 1 +    for i in range(1, n + 1): +        dog *= i +        dog = dog % mod +    for i in range(1, m + 1): +        cat *= i +        cat = cat % mod +    print((dog * cat % mod)) -    ans = math.factorial(n) * math.factorial(m) -    print((ans % mod)) +    dog = 1 +    cat = 1 +    for i in range(1, n + 1): +        dog *= i +        dog = dog % mod +    for i in range(1, m + 1): +        cat *= i +        cat = cat % mod +    print((dog * cat * 2 % mod))