import math

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



if abs(n-m)>=2:

    print((0))

if abs(n-m)==1:

    print((math.factorial(m)*math.factorial(n)%1000000007))

if n==m:

    print((math.factorial(m)*math.factorial(n)*2%1000000007)) 
n,m = list(map(int,(input().split())))

mod = 10**9+7



sn,sm = 1,1

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

    sn = sn*i%mod

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

    sm = sm*i%mod



if abs(n-m)>=2:

    print((0))

elif abs(n-m) == 1:

    print((sn*sm%mod))

elif abs(n-m) == 0:

    print((sn*sm*2%mod))
import math

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

n, m = list(map(int, (input().split())))
mod = 10**9 + 7
sn, sm = 1, 1
for i in range(1, n + 1):
    sn = sn * i % mod
for i in range(1, m + 1):
    sm = sm * i % mod
if abs(n - m) >= 2:
    print((0))
elif abs(n - m) == 1:
    print((sn * sm % mod))
elif abs(n - m) == 0:
    print((sn * sm * 2 % mod))

-import math - -n, m = list(map(int, input().split())) +n, m = list(map(int, (input().split()))) +mod = 10**9 + 7 +sn, sm = 1, 1 +for i in range(1, n + 1): +    sn = sn * i % mod +for i in range(1, m + 1): +    sm = sm * i % mod -if abs(n - m) == 1: -    print((math.factorial(m) * math.factorial(n) % 1000000007)) -if n == m: -    print((math.factorial(m) * math.factorial(n) * 2 % 1000000007)) +elif abs(n - m) == 1: +    print((sn * sm % mod)) +elif abs(n - m) == 0: +    print((sn * sm * 2 % mod))