import math

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

if abs(N-M)>1:

    print((0))

    exit()

IF = 10**9+7

ans = math.factorial(N)*math.factorial(M)

if abs(N-M)==0:

    ans*=2

print((ans%IF))
N,M = list(map(int,input().split()))

mod = pow(10,9)+7



def f(x,mod):

    k = 1

    res = 1

    while k<x:

        k+=1

        res*=k

        res %= mod

    return res



if abs(N-M)>1:print((0))

elif abs(N-M)==1:

    a = f(min(N,M),mod)

    print((pow(a,2,mod)*max(N,M)%mod))

else:

    a = f(N,mod)

    print((2*pow(a,2,mod)%mod))
import math

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

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


def f(x, mod):
    k = 1
    res = 1
    while k < x:
        k += 1
        res *= k
        res %= mod
    return res


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

-import math +N, M = list(map(int, input().split())) +mod = pow(10, 9) + 7 -N, M = list(map(int, input().split())) + +def f(x, mod): +    k = 1 +    res = 1 +    while k < x: +        k += 1 +        res *= k +        res %= mod +    return res + + -    exit() -IF = 10**9 + 7 -ans = math.factorial(N) * math.factorial(M) -if abs(N - M) == 0: -    ans *= 2 -print((ans % IF)) +elif abs(N - M) == 1: +    a = f(min(N, M), mod) +    print((pow(a, 2, mod) * max(N, M) % mod)) +else: +    a = f(N, mod) +    print((2 * pow(a, 2, mod) % mod))