import math

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

a=math.factorial(n)

b=math.factorial(m)

if n==m:

  print(((2*a**2)%(10**9+7)))

elif abs(n-m)==1:

  print(((a*b)%(10**9+7)))

else:

  print((0))

def fact(n):

  if n==1:

    return 1

  else:

    c=1

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

      c=(c*i)%(10**9+7)

    return c

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

if n==m:

  print(((2*(fact(n)**2))%(10**9+7)))

elif abs(n-m)==1:

  print((fact(n)*fact(m)%(10**9+7)))

else:

  print((0))
import math

n, m = list(map(int, input().split()))
a = math.factorial(n)
b = math.factorial(m)
if n == m:
    print(((2 * a**2) % (10**9 + 7)))
elif abs(n - m) == 1:
    print(((a * b) % (10**9 + 7)))
else:
    print((0))

def fact(n):
    if n == 1:
        return 1
    else:
        c = 1
        for i in range(1, n + 1):
            c = (c * i) % (10**9 + 7)
        return c


n, m = list(map(int, input().split()))
if n == m:
    print(((2 * (fact(n) ** 2)) % (10**9 + 7)))
elif abs(n - m) == 1:
    print((fact(n) * fact(m) % (10**9 + 7)))
else:
    print((0))

-import math +def fact(n): +    if n == 1: +        return 1 +    else: +        c = 1 +        for i in range(1, n + 1): +            c = (c * i) % (10**9 + 7) +        return c + -a = math.factorial(n) -b = math.factorial(m) -    print(((2 * a**2) % (10**9 + 7))) +    print(((2 * (fact(n) ** 2)) % (10**9 + 7))) -    print(((a * b) % (10**9 + 7))) +    print((fact(n) * fact(m) % (10**9 + 7)))