# ==================== mod 10**9+7    

mod=10**9+7



def mul(a, b):

    return ((a % mod) * (b % mod)) % mod





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



if n==1 and m==1:

    print((2))

elif n==2 and m==1:

    print((2))

elif n==1 and m==2:

    print((2))

elif n==2 and m==2:

    print((8))

elif n+2<=m:

    print((0))

elif n+1==m:

    k=1

    for i in range(1,n):

        k=mul(k,i+1)

    for i in range(1,m):

        k=mul(k,i+1)

    print(k)

elif n==m:

    k=1

    for i in range(1,n):

        k=mul(k,i+1)

    for i in range(1,m):

        k=mul(k,i+1)

    k=mul(k,2)

    print(k)

elif n==m+1:

    k=1

    for i in range(1,n):

        k=mul(k,i+1)

    for i in range(1,m):

        k=mul(k,i+1)

    print(k)

elif n>=m+2:

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



if abs(n-m)>=2:

    print((0))

else:

    nm=1

    p=10**9+7

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

        nm=nm*ni%p

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

        nm=nm*ni%p

    if abs(n-m)==1:

        print(nm)

    else:

        print(((2*nm)%p))
# ==================== mod 10**9+7
mod = 10**9 + 7


def mul(a, b):
    return ((a % mod) * (b % mod)) % mod


n, m = list(map(int, input().split()))
if n == 1 and m == 1:
    print((2))
elif n == 2 and m == 1:
    print((2))
elif n == 1 and m == 2:
    print((2))
elif n == 2 and m == 2:
    print((8))
elif n + 2 <= m:
    print((0))
elif n + 1 == m:
    k = 1
    for i in range(1, n):
        k = mul(k, i + 1)
    for i in range(1, m):
        k = mul(k, i + 1)
    print(k)
elif n == m:
    k = 1
    for i in range(1, n):
        k = mul(k, i + 1)
    for i in range(1, m):
        k = mul(k, i + 1)
    k = mul(k, 2)
    print(k)
elif n == m + 1:
    k = 1
    for i in range(1, n):
        k = mul(k, i + 1)
    for i in range(1, m):
        k = mul(k, i + 1)
    print(k)
elif n >= m + 2:
    print((0))

n, m = list(map(int, input().split()))
if abs(n - m) >= 2:
    print((0))
else:
    nm = 1
    p = 10**9 + 7
    for ni in range(1, n + 1):
        nm = nm * ni % p
    for ni in range(1, m + 1):
        nm = nm * ni % p
    if abs(n - m) == 1:
        print(nm)
    else:
        print(((2 * nm) % p))

-# ==================== mod 10**9+7 -mod = 10**9 + 7 - - -def mul(a, b): -    return ((a % mod) * (b % mod)) % mod - - -if n == 1 and m == 1: -    print((2)) -elif n == 2 and m == 1: -    print((2)) -elif n == 1 and m == 2: -    print((2)) -elif n == 2 and m == 2: -    print((8)) -elif n + 2 <= m: +if abs(n - m) >= 2: -elif n + 1 == m: -    k = 1 -    for i in range(1, n): -        k = mul(k, i + 1) -    for i in range(1, m): -        k = mul(k, i + 1) -    print(k) -elif n == m: -    k = 1 -    for i in range(1, n): -        k = mul(k, i + 1) -    for i in range(1, m): -        k = mul(k, i + 1) -    k = mul(k, 2) -    print(k) -elif n == m + 1: -    k = 1 -    for i in range(1, n): -        k = mul(k, i + 1) -    for i in range(1, m): -        k = mul(k, i + 1) -    print(k) -elif n >= m + 2: -    print((0)) +else: +    nm = 1 +    p = 10**9 + 7 +    for ni in range(1, n + 1): +        nm = nm * ni % p +    for ni in range(1, m + 1): +        nm = nm * ni % p +    if abs(n - m) == 1: +        print(nm) +    else: +        print(((2 * nm) % p))