CodeEff/ECCO huggingface dataset:
# Original solution
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
    return val

if abs(n-m)>1:
    print((0))
elif abs(n-m)==1:
    print((factorial(max(m,n))**2//max(m,n)%mod))
else:
    print((factorial(n)**2*2%mod))


# Optimized solution
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val %= mod
    return val

if abs(n-m)>1:
    print((0))
elif abs(n-m)==1:
    num = factorial(min(m,n))
    print((num**2*max(m,n)%mod))
else:
    num = factorial(m)
    print((num**2*2%mod))
# Original solution
from math import factorial

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

a = 10**9+7
if abs(N-M) >= 2:
    print((0))

elif N == M:
    print(((2*factorial(N)*factorial(M)) % a))

else:
    print(((factorial(N)*factorial(M)) % a))


# Optimized solution
def factorial(n):
    ans = 1
    for i in range(2, n + 1):
        ans = ans * i % 1000000007
    return ans


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

MAD = 10**9+7
if abs(N-M) >= 2:
    print((0))

elif N == M:
    print(((2*factorial(N)*factorial(M)) % MAD))

else:
    print(((factorial(N)*factorial(M)) % MAD))
# Original solution
n, m = list(map(int,input().split()))

mod = 10**9 + 7

if abs(n-m) > 1:
    print((0))
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)

    for i in range(1,b+1):
        ans *= (i%mod)
    print((ans%mod))

else:
    ans = 1
    for i in range(1,n+1):
        ans *= (i%mod)
    for i in range(1,n+1):
        ans *= (i%mod)
    print(((2*ans)%mod))

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

mod = 10**9 + 7

if abs(n-m) > 1:
    print((0))
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,b+1):
        ans *= (i%mod)
        ans %= mod
    print((ans%mod))

else:
    ans = 1
    for i in range(1,n+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,n+1):
        ans *= (i%mod)
        ans %= mod
    print(((2*ans)%mod))
# Original solution
n, m = list(map(int,input().split()))

mod = 10**9 + 7

if abs(n-m) > 1:
    print((0))
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,b+1):
        ans *= (i%mod)
        ans %= mod
    print((ans%mod))

else:
    ans = 1
    for i in range(1,n+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,n+1):
        ans *= (i%mod)
        ans %= mod
    print(((2*ans)%mod))

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

mod = 10**9 + 7

if abs(n-m) > 1:
    print((0))
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,b+1):
        ans *= (i%mod)
        ans %= mod
    print((ans%mod))

else:
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(((2*ans)%mod))
# Original solution
import math

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

if abs(N - M) > 1:
    print((0))
elif abs(N - M) == 1:
    print((math.factorial(N) * math.factorial(M)))
else:
    print(((math.factorial(N) ** 2 * 2) % (10 ** 9 + 7)))


# Optimized solution
import math

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

if abs(N - M) > 1:
    print((0))
elif abs(N - M) == 1:
    print(((math.factorial(N) * math.factorial(M)) % (10 ** 9 + 7)))
else:
    print(((math.factorial(N) ** 2 * 2) % (10 ** 9 + 7)))
# Original solution
def lam(x):
	ans=1
	for i in range(1,x+1):
		ans*=i
	return ans
n,m=list(map(int,input().split()))
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print((0))
	exit()
if n+1==m:
	print((lam(n)*lam(m)%mod))
else:
	print((2*lam(n)**2%mod))


# Optimized solution
def lam(x,mo):
	ans=1
	for i in range(1,x+1):
		ans*=i
		ans%=mo
	return ans
n,m=list(map(int,input().split()))
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print((0))
	exit()
if n+1==m:
	print((lam(n,mod)*lam(m,mod)%mod))
else:
	print((2*(lam(n,mod)**2)%mod))
# Original solution
from math import factorial
n,m = list(map(int,input().split()))
if abs(n-m) > 1:
  print((0))
elif n == m:
  ans = 2*factorial(n)**2
  print(ans)
else:
  ans = factorial(n)*factorial(m)
  print(ans)

# Optimized solution
from math import factorial
n,m = list(map(int,input().split()))
if abs(n-m) > 1:
  print((0))
elif n == m:
  ans = 2*(factorial(n)%(10**9+7))**2%(10**9+7)
  print(ans)
else:
  ans = (factorial(n)%(10**9+7))*(factorial(m)%(10**9+7))%(10**9+7)
  print(ans)
# Original solution
# 差が1か0のみ隣り合わない 適当に毎回割る再帰

n, m = list(map(int, input().split()))
if abs(n - m) > 1:
    print((0))
elif n == m:
    ans = 1
    while n > 0:
        ans *= n
        n -= 1
        ans %= (10 ** 9 + 7)
    ans = (ans * ans * 2) % (10 ** 9 + 7)
    print(ans)
else:
    ans = max(n, m)
    t = 1
    x = min(n, m)
    while x > 0:
        t *= x
        x -= 1
        t %= (10 ** 9 + 7)
    ans = (ans * t * t) % (10 ** 9 + 7)
    print(ans)


# Optimized solution
n, m = list(map(int, input().split()))
MOD = 10**9 + 7

if abs(n - m) > 1:
    print((0))
elif n == m:
    ans = 1
    for i in range(2, n + 1):
        ans *= i
        ans %= MOD
    # xoxoxo... とoxoxox... 、どっちを先にするかで2種類
    print((2 * ans * ans % MOD))
else:
    ans = 1
    for i in range(2, n + 1):
        ans *= i
        ans %= MOD
    for i in range(2, m + 1):
        ans *= i
        ans %= MOD
    print(ans)
# Original solution
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)) 

# Optimized solution
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))
# Original solution
n, m = list(map(int, input().split()))
MOD = 1000000007
ans = 1
if abs(n - m) == 1:
    for i in range(1, min(n, m) + 1):
        ans *= (i ** 2) % MOD
    ans = (ans * max(n, m)) % MOD
elif n == m:
    for i in range(1, min(n, m) + 1):
        ans *= (i ** 2) % MOD
    ans =  (ans * 2) % MOD
else:
    ans = 0
print(ans)


# Optimized solution
from math import factorial
n, m = list(map(int, input().split()))
MOD = 1000000007
if abs(n - m) == 1:
    ans = max(n, m)
elif n == m:
    ans = 2
else:
    ans = 0
ans *= ((factorial(min(n, m)) % MOD)) ** 2
ans %= MOD
print(ans)
# Original solution
import math as m

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

if abs(N-M)>=2:
  print((0))
else:
  N,M=max(N,M),min(N,M)
  
  Pm=1
  for i in range(1,M+1):
    Pm*=i
    Pm%=10**9+7

  Pn=1
  for i in range(1,N+1):
    Pn*=i
    Pn%=10**9+7

    
  print(((Pm*Pn*1)%(10**9+7) if M!=N else (Pm*Pn*2)%(10**9+7)))
 

# Optimized solution
N, M = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def permutation(n):
  res = 1
  for i in range(1, n + 1):
    res = (res * i) % MOD
  return res

if abs(N - M) >= 2:
  print((0))
else:
  if N == M:
    print(((permutation(N) * permutation(M) * 2) % MOD))
  else:
    N, M = max(N, M), min(N, M)
    print(((permutation(N) * permutation(M)) % MOD))
# Original solution
from math import factorial as F
N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9+7

if M-N > 1:
    print((0))
elif M-N == 1:
    print((F(M)*F(N) % mod))
else:
    print((F(M)**2*2 % mod))


# Optimized solution
N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9+7

g = [1, 1]
for i in range(2, M+1):
    g.append((g[-1] * i) % mod)

if M-N > 1:
    print((0))
elif M-N == 1:
    print((g[M]*g[N] % mod))
else:
    print((g[M]**2*2 % mod))
# Original solution
n,m = list(map(int,input().split()))
if abs(n-m) != 0 and abs(n-m) != 1 :
    print((0))
else:
    x = 1
    for i in range(1,min(n,m)+1):
        x = x * i

    if abs(n-m) == 0:
        print(((2 * x * x)%(10**9+7)))
    else:
        print(((x * x * max(n,m))%(10**9+7)))

# Optimized solution
import math
n,m = list(map(int,input().split()))
if abs(n-m) != 0 and abs(n-m) != 1 :
    print((0))
else:
    x = math.factorial(min(m,n))

    if abs(n-m) == 0:
        print(((2 * x * x)%(10**9+7)))
    else:
        print(((x * x * max(n,m))%(10**9+7)))
# Original solution
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=list(map(int,input().split()))
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    if n==m:
        s=kaijo(n)
        ans=2*s*s
    else:
        if n>m:
            s=kaijo(m)
            ans=s*s*n
        else:
            s=kaijo(n)
            ans=s*s*m

print((ans%mod))


# Optimized solution
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


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

print(ans)
# Original solution
N, M = list(map(int, input().split()))
MOD = 10 ** 9 + 7

fact = [1, 1]
for i in range(2, max(N, M) + 1):
    fact.append((i * fact[i - 1]) % MOD)

if abs(N - M) >= 2:
    print((0))
elif abs(N - M) == 0:
    print(((fact[N] * fact[M] * 2) % MOD))
else:
    print(((fact[N] * fact[M]) % MOD))


# Optimized solution
N, M = list(map(int, input().split()))
MOD = 10 ** 9 + 7

fact = [0] * (max(N, M) + 1)
fact[1] = 1
for i in range(2, max(M, N) + 1):
    fact[i] = fact[i - 1] * i % MOD

if abs(N - M) > 1:
    print((0))
else:
    ans = fact[N] * fact[M] % MOD
    if N == M:
        ans *= 2
        ans %= MOD
    print(ans)
# Original solution
n,m=list(map(int,input().split()))
mod=10**9+7
def kaijou(x):
  y=1
  for i in range(1,x+1):
    y*=i
  return y
if abs(n-m)>=2:
  print((0))
elif n==m:
  print((kaijou(n)*kaijou(m)*2))
else:
  print((kaijou(n)*kaijou(m)))

# Optimized solution
n,m=list(map(int,input().split()))
mod=10**9+7
def kaijou(x):
  y=1
  for i in range(1,x+1):
    y*=i
    y%=mod
  return y
if abs(n-m)>=2:
  print((0))
elif n==m:
  print(((kaijou(n)*kaijou(m)*2)%mod))
else:
  print(((kaijou(n)*kaijou(m))%mod))
# Original solution
# https://atcoder.jp/contests/abc065/tasks/arc076_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    mod = 10**9 + 7

    if abs(N - M) > 1:
        print((0))
        exit()

    n = 1
    for i in range(1, N + 1):
        n *= i
    m = 1
    for i in range(1, M + 1):
        m *= i

    if N == M:
        print(((n * m * 2) % mod))
    else:
        print(((n * m) % mod))

if __name__ == '__main__':
    main()


# Optimized solution
# https://atcoder.jp/contests/abc065/tasks/arc076_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    mod = 10**9 + 7

    if abs(N - M) > 1:
        print((0))
        exit()

    n = 1
    m = 1
    for i in range(1, N + 1):
        n = (n * i) % mod
    for i in range(1, M + 1):
        m = (m * i) % mod

    if N == M:
        print(((n * m * 2) % mod))
    else:
        print(((n * m) % mod))

if __name__ == '__main__':
    main()
# Original solution
import math
mod = 10**9+7
n,m = list(map(int,input().split()))
if n!=m and abs(n-m)!=1:
    print("0")
    exit()

if n==m:
    n=max(n,m)
    m=min(n,m)
    ans = math.factorial(n)*2*math.factorial(m)
    print((ans%mod))
else:
    ans = math.factorial(n)*math.factorial(m)
    print((ans%mod))



# Optimized solution

n,m=list(map(int,input().split()))
if 2<=abs(n-m):
    print((0))
    exit()
mod=10**9+7

if abs(n-m)==1:
    dog=1
    cat=1
    for i in range(1,n+1):
        dog*=i
        dog=dog%mod
    for i in range(1,m+1):
        cat*=i
        cat=cat%mod
    print((dog*cat%mod))
else:
    dog=1
    cat=1
    for i in range(1,n+1):
        dog*=i
        dog=dog%mod
    for i in range(1,m+1):
        cat*=i
        cat=cat%mod
    print((dog*cat*2%mod))
# Original solution
from math import factorial

n, m = list(map(int, input().split()))
if n == m:
    print((2 * factorial(n)**2 % 1000000007))
elif abs(n - m) < 2:
    print((factorial(max(n, m)) * factorial(min(n, m) % 1000000007)))
else:
    print((0))


# Optimized solution
from math import factorial

n, m = list(map(int, input().split()))
if n == m:
    print((2 * factorial(n)**2 % 1000000007))
elif abs(n - m) < 2:
    print((factorial(n) * factorial(m) % 1000000007))
else:
    print((0))
# Original solution
from math import factorial

n, m = list(map(int, input().split()))
if n == m:
    print((2 * factorial(n)**2 % 1000000007))
elif abs(n - m) < 2:
    print((factorial(n) * factorial(m) % 1000000007))
else:
    print((0))


# Optimized solution
n, m = sorted(map(int, input().split()))
mod = 10**9 + 7


def factorial(n):
    ans = 1
    for i in range(1, n + 1):
        ans *= i
        ans %= mod
    return ans
if n == m:
    ans = factorial(n)
    print((ans ** 2 * 2 % mod))
elif m - n == 1:
    ans = factorial(n)
    print((ans ** 2 * m % mod))
else:
    print((0))
# Original solution
import math
m,n=list(map(int,input().split()))
f=abs(m-n)
if f == 0:
  ans=2*math.factorial(m)*math.factorial(n)
  print(ans)
  exit()
elif f == 1:
  ans=math.factorial(m)*math.factorial(n)
  print(ans)
  exit()
else:
  print((0))
  exit()

# Optimized solution
import math
MOD = 1000000007
m,n=list(map(int,input().split()))
f=abs(m-n)
if f == 0:
  ans=2*math.factorial(m)*math.factorial(n)%MOD
  print(ans)
  exit()
elif f == 1:
  ans=math.factorial(m)*math.factorial(n)%MOD
  print(ans)
  exit()
else:
  print((0))
  exit()
# Original solution
import math
N,M=list(map(int,input().split()))
x=math.factorial(N)
y=math.factorial(M)
if(abs(N-M)>1):
    print((0))
else:
    if((N%2==0 and M%2==0) or N==M):
        print((x*y*2%(10**9+7)))
    else:
        print((x*y))

# Optimized solution
import math
N,M=list(map(int,input().split()))
x=math.factorial(N)*math.factorial(M)%(10**9+7)
if(abs(N-M)>1):
    print((0))
else:
    if((N%2==0 and M%2==0) or N==M):
        print((x*2%(10**9+7)))
    else:
        print(x)
# Original solution
import math

N,M = list(map(int,input().split()))
if abs(N-M) >= 2:
    print((0))
    exit()
elif abs(N-M) == 1:
    print((math.factorial(N)*math.factorial(M)))
else:
    print((math.factorial(N)*math.factorial(M)*2))

# Optimized solution
import math

N,M = list(map(int,input().split()))
if abs(N-M) >= 2:
    print((0))
    exit()
elif abs(N-M) == 1:
    res = math.factorial(N)*math.factorial(M)
    print((res%(10**9+7)))
else:
    res = math.factorial(N)*math.factorial(M) * 2
    print((res%(10**9+7)))
# Original solution
import sys
input = sys.stdin.readline

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

    MOD = int(1e9) + 7

    tmp = abs(N - M)
    if tmp >= 2:
        print((0))
    else:
        ans = 2
        if tmp == 1:
            ans = 1
        for i in range(2, N+1):
            ans *= i
            ans = ans % MOD
        for i in range(2, M+1):
            ans *= i
            ans = ans % MOD
        print(ans)

if __name__ == "__main__":
    main()


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

MOD = int(1e9) + 7

tmp = abs(N - M)
if tmp >= 2:
    print((0))
else:
    ans = 2
    if tmp == 1:
        ans = 1
    for i in range(2, N+1):
        ans *= i
        ans = ans % MOD
    for i in range(2, M+1):
        ans *= i
        ans = ans % MOD
    print(ans)
# Original solution
from math import factorial

def fac(n, mod):
    res = 1
    for i in range(1, n + 1):
        res = res * i % mod
    return res


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

# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    if abs(n - m) >= 2:
        print((0))
        exit()

    fact = [1]
    for i in range(2, max(n, m) + 1):
        fact.append((fact[-1] * i) % mod)

    res = fact[n - 1] * fact[m - 1] % mod
    print((res if n != m else res * 2 % mod))


if __name__ == '__main__':
    resolve()
# Original solution
import math

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

if abs(N-M)>=2:
    print((0))
elif abs(N-M)==1:
    print((math.factorial(N)*math.factorial(M)))
else:
    print(((2*math.factorial(N)*math.factorial(M))%(10**9+7)))  

# Optimized solution
import math

def f(n):
    if n==1:
        return 1
    return n*f(n-1)

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

if abs(N-M)>=2:
    print((0))
elif abs(N-M)==1:
    print((math.factorial(N)*math.factorial(M)%(10**9+7)))
else:
    print(((2*math.factorial(N)*math.factorial(M))%(10**9+7)))
# Original solution
import math
def fact(n):
    return math.factorial(n)

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))

# Optimized solution
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))
# Original solution
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))

# Optimized solution
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))
# Original solution
import math
n, m = list(map(int, input().split()))
div = 10**9 + 7

if abs(n-m)>1:
    print((0))
    exit()
elif n == m:
    ans1 = math.factorial(n)
    ans2 = math.factorial(m)
    ans = 2 * ans1 * ans2 
else:
    ma = max(n,m)
    mi = min(n,m)
    ans1 = math.factorial(ma)
    ans2 = math.factorial(mi)
    ans = ans2*ans1

print((ans % div))

    
    

# Optimized solution
import math
n, m = list(map(int, input().split()))
div = 10**9 + 7

if abs(n-m)>1:
    print((0))
    exit()
elif n == m:
    ans1 = math.factorial(n)
    ans2 = math.factorial(m)
    ans = 2 * ans1 * ans2 
else:
    ans1 = math.factorial(n)
    ans2 = math.factorial(m)
    ans = ans2*ans1

print((ans % div))
# Original solution
N, M = list(map(int, input().split()))
ans = 0
nn = 1
mm = 1
for i in range(1, N+1):
    nn *= i
for i in range(1, M+1):
    mm *= i

if N == M:
    ans = ((2*nn*mm)%(10**9+7))

elif abs(N-M) ==1:
    ans = ((nn*mm)%(10**9+7))

print(ans)

# Optimized solution
N, M = list(map(int, input().split()))
ans = 0
nn = 1
mm = 1
for i in range(1, N+1):
    nn = (nn*i)%(10**9+7)
for i in range(1, M+1):
    mm = (mm*i)%(10**9+7)

if N == M:
    ans = ((2*nn*mm)%(10**9+7))

elif abs(N-M) ==1:
    ans = ((nn*mm)%(10**9+7))

print(ans)
# Original solution
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))


# Optimized solution
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))
# Original solution
import sys
n,m=list(map(int,input().split()))
if abs(n-m)>1:
  print((0))
  sys.exit()
cnt=1
for i in range(1,n+1):
  cnt*=i
if n==m:
  print((2*((cnt**2)%((10**9)+7))))
if n-m==1:
  print(((cnt*(cnt//n))%((10**9)+7)))
if m-n==1:
  print(((cnt*cnt*m)%((10**9)+7)))


# Optimized solution
import sys
n,m=list(map(int,input().split()))
num=n
mum=m
if 2<=abs(n-m):
  print((0))
  sys.exit()
if abs(n-m)==1:
  while n>1:
    num*=n-1
    n-=1
    num=num%((10**9)+7)
  while m>1:
    mum*=m-1
    m-=1
    mum=mum%((10**9)+7)
  print(((num*mum)%((10**9)+7)))
  sys.exit()
if abs(n-m)==0:
  while n>1:
    num*=n-1
    n-=1
    num=num%((10**9)+7)
  print(((2*(num**2))%((10**9)+7)))
  sys.exit()
# Original solution
n,m = list(map(int,input().split()))
mod = 10**9+7

if abs(n -m) > 1:
    print((0))
    
if  abs(n -m) == 0:
    n_ans = 1
    m_ans = 1
    for i in range(1,n+1):
        n_ans *= i%mod
    for i in range(1,m+1):
        m_ans *= i%mod
    print((2*n_ans*m_ans%mod))
    
if abs(n -m) == 1:
    n_ans = 1
    m_ans = 1
    for i in range(1,n+1):
        n_ans *= i%mod
    for i in range(1,m+1):
        m_ans *= i%mod
    print((n_ans*m_ans%mod))

# Optimized solution
n,m = list(map(int,input().split()))
mod = 10**9+7

if abs(n -m) > 1:
    print((0))
    
if  abs(n -m) == 0:
    n_ans = 1
    m_ans = 1
    for i in range(1,n+1):
        n_ans *= i
        n_ans %= mod
    for i in range(1,m+1):
        m_ans *= i
        m_ans %= mod
    print((2*n_ans*m_ans%mod))
    
if abs(n -m) == 1:
    n_ans = 1
    m_ans = 1
    for i in range(1,n+1):
        n_ans *= i
        n_ans %= mod
    for i in range(1,m+1):
        m_ans *= i
        m_ans %= mod
    print((n_ans*m_ans%mod))
# Original solution
N,M=list(map(int,input().split()))
abs_NM=abs(N-M)
if abs_NM>1:
    print((0))
    exit()

p=10**9+7
ans=1
for i in range(1,N+1):
    ans=(ans*i)%p
for i in range(1,M+1):
    ans=(ans*i)%p
if abs_NM==0:
    ans=(ans*2)%p

print(ans)

# Optimized solution
N,M=list(map(int,input().split()))
abs_NM=abs(N-M)
if abs_NM>1:
    print((0))
    exit()

p=10**9+7
min_=min(N,M)
max_=max(N,M)
ans=1
for i in range(1,min_+1):
    ans=(ans*i)%p
    ans=(ans*i)%p

if abs_NM==1:
    ans=(ans*max_)%p
else:
    ans=(ans*2)%p

print(ans)
# Original solution
# ==================== 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))

# Optimized solution
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))
# Original solution
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))))

# Optimized solution
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))