import math

def fact(n):

    mod = int(1e9)+7

    return math.factorial(n)%mod



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



if abs(N-M) >= 2:

    print((0))

    exit()



mod = int(1e9)+7



if N == M:

    print((2*fact(N)*fact(M)%mod))

else:

    print((fact(N)*fact(M)%mod))
def fact(n):

    mod = int(1e9)+7

    res = 1

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

        res = (res*i)%mod

    return res



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



if abs(N-M) >= 2:

    print((0))

    exit()



mod = int(1e9)+7



if N == M:

    print((2*fact(N)*fact(M)%mod))

else:

    print((fact(N)*fact(M)%mod))
import math


def fact(n):
    mod = int(1e9) + 7
    return math.factorial(n) % mod


N, M = list(map(int, input().split()))
if abs(N - M) >= 2:
    print((0))
    exit()
mod = int(1e9) + 7
if N == M:
    print((2 * fact(N) * fact(M) % mod))
else:
    print((fact(N) * fact(M) % mod))

def fact(n):
    mod = int(1e9) + 7
    res = 1
    for i in range(1, n + 1):
        res = (res * i) % mod
    return res


N, M = list(map(int, input().split()))
if abs(N - M) >= 2:
    print((0))
    exit()
mod = int(1e9) + 7
if N == M:
    print((2 * fact(N) * fact(M) % mod))
else:
    print((fact(N) * fact(M) % mod))

-import math - - -    return math.factorial(n) % mod +    res = 1 +    for i in range(1, n + 1): +        res = (res * i) % mod +    return res