import math

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



if abs(n-m)>1:

  print((0))

elif n-m==1:

  print((int((math.factorial(n)*math.factorial(m))%(10**9+7))))

elif m-n==1:

  print((int((math.factorial(m)*math.factorial(n))%(10**9+7))))

elif n==m:

  print((int((math.factorial(n)*math.factorial(m)*2)%(10**9+7))))
from math import factorial

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

l=10**9+7

if abs(n-m)>1:

  print((0))

  exit()

if abs(n-m)==1:

  print(((factorial(n)*factorial(m))%l))

else:

  print((((factorial(n)**2)*2)%l))
import math

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

from math import factorial

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

-import math +from math import factorial +l = 10**9 + 7 -elif n - m == 1: -    print((int((math.factorial(n) * math.factorial(m)) % (10**9 + 7)))) -elif m - n == 1: -    print((int((math.factorial(m) * math.factorial(n)) % (10**9 + 7)))) -elif n == m: -    print((int((math.factorial(n) * math.factorial(m) * 2) % (10**9 + 7)))) +    exit() +if abs(n - m) == 1: +    print(((factorial(n) * factorial(m)) % l)) +else: +    print((((factorial(n) ** 2) * 2) % l))