CodeEff/ECCO huggingface dataset:
# Original solution
def resolve():
    '''
    code here

    '''
    import math

    N, M = [int(item) for item in input().split()]

    deff = N - M

    if deff == 0:
        temp = math.factorial(N)
        res = (temp**2 * 2) % (10**9+7)

    elif abs(deff) == 1:
        res = (math.factorial(N) * math.factorial(M)) % (10**9+7)

    else:
        res = 0
    
    print(res)

if __name__ == "__main__":
    resolve()


# Optimized solution
def resolve():
    '''
    code here

    '''
    import math

    N, M = [int(item) for item in input().split()]

    deff = N - M

    if deff == -1:
        N, M = M, N

    if deff == 0:
        temp = math.factorial(N)
        res = (temp**2 * 2) % (10**9+7)

    elif abs(deff) == 1:
        res = (math.factorial(N) **2 // N ) % (10**9+7)

    else:
        res = 0
    
    print(res)

if __name__ == "__main__":
    resolve()
# Original solution
nums = [1, 1]
def step_div(n):
	i = len(nums)
	while i <= n:
		nums.append(nums[i-1] * i)
		i += 1
	return nums[n]

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

remain = abs(n-m)
if remain <= 1:
	print(((step_div(n) * step_div(m) * (2 if remain==0 else 1)) % (10**9+7)))
else:
	print((0))

# Optimized solution
import math

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

remain = abs(n-m)
if remain <= 1:
	print(((math.factorial(n) * math.factorial(m) * (2 if remain==0 else 1)) % (10**9+7)))
else:
	print((0))
# Original solution
N, M = [int(i) for i in input().split()]

mod = 10 ** 9 + 7

def mod_fact(n, mod = 10 ** 9 + 7):
    result = 1
    for i in range(2, n + 1):
        result = (result * i) % mod
    return result

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


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

mod = 10 ** 9 + 7

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

if N == M:
    print((2 * mod_fact(N, mod) ** 2 % mod))
elif abs(N - M) == 1:
    print((mod_fact(min(M, N), mod) ** 2 * max(M, N) % mod))
else:
    print((0))
# Original solution
mod = 10**9+7

def kaizyou(x):
    y = 1
    while x != 0:
        y *= x
        x -= 1
    return y%mod


N , M = list(map(int, input().split()))
if abs(N-M) >= 2:
    ans = 0
elif N == M:
    ans = 2 * kaizyou(N) ** 2
elif N > M:
    ans = N * kaizyou(M) ** 2
else:
    ans = M * kaizyou(N) ** 2
print((ans%mod))

# Optimized solution
mod = 10**9+7

def kaizyou(x):
    y = 1
    for i in range(2, x+1):
        y = (y*i)%mod
    return y


N , M = list(map(int, input().split()))
if abs(N-M) >= 2:
    ans = 0
elif N == M:
    ans = 2 * kaizyou(N) ** 2
elif N > M:
    ans = N * kaizyou(M) ** 2
else:
    ans = M * kaizyou(N) ** 2
print((ans%mod))
# Original solution
import sys
sys.setrecursionlimit(1000000)

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

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

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

n_frac = frac(N)
m_frac = frac(M)
if N-M == 0:
    print(((n_frac*m_frac)*2))
else:
    print((n_frac*m_frac))





# Optimized solution
from math import factorial

N,M = list(map(int, input().split()))
mod = 10 ** 9 + 7

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

n_frac = factorial(N) 
m_frac = n_frac
if N-M == 0:
    print(((n_frac*m_frac)*2%mod))
else:
    if N > M:
        m_frac //= N
    else:
        m_frac *=  M
    print((n_frac*m_frac%mod))
# Original solution
from math import factorial
MOD = 10**9 + 7
n, m = list(map(int, input().split()))
if n == m:
    print((2 * factorial(n)**2 % MOD))
elif n - 1 == m:
    print((n * factorial(m)**2 % MOD))
elif n == m - 1:
    print((m * factorial(n)**2 % MOD))
else:
    print((0))

# 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()))
MOD = 10**9 + 7
if n == m:
    print((2 * factorial(n) ** 2 % MOD))
elif abs(n - m) == 1:
    print((factorial(min(m, n)) ** 2 * max(m, n) % MOD))
else:
    print((0))
# Original solution
import math

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

if N == M:
    ans = math.factorial(N) ** 2 * 2
elif N - M == 1:
    ans = math.factorial(N) * math.factorial(M)
else:
    ans = 0

print(ans)


# Optimized solution
import math

N, M = list(map(int, input().split()))
N, M = max(N,M), min(N,M)
MOD = 10**9+7

if N == M:
    ans = math.factorial(N) ** 2 * 2
elif N - M == 1:
    ans = math.factorial(M) ** 2 * N
else:
    ans = 0

print((ans % MOD))
# Original solution
import math
n, m = list(map(int,input().split()))
mod = (10**9)+7
N = math.factorial(n)
M = math.factorial(m)
mul = 0 if abs(n-m)>1 else 2 if n==m else 1 
print((N*M*mul%mod))

# Optimized solution
import math
n, m = list(map(int,input().split()))
mod = (10**9)+7
mul = 0 if abs(n-m)>1 else 2 if n==m else 1
a = min(n,m)
A = math.factorial(a)
B = A
if mul==1:
  B*=max(n,m)
print((A*B*mul%mod))
# Original solution
n,m = list(map(int,input().split()))
diff = abs(n-m)
count1 = 1
count2 = 1
a = 1

def saiki(n):
    if n<=1:
        return 1
    return n * saiki(n-1)
if diff >= 2:
    print((0))
elif diff == 1:
    for i in range(1,max(n,m)+1):
        count1 *= i
    '''
    for i in range(1,(min(n,m)+1)):
        count2 *= i
    '''

    print((count1*(count1//max(n,m))%(10**9+7)))
else:
    for i in range(1,n+1):
        count1 *= i
    print((count1*count1*2%(10**9+7)))


# Optimized solution
import math
n,m = list(map(int,input().split()))
diff = abs(n-m)
count1 = 1
count2 = 1
a = 1

if diff >= 2:
    print((0))
elif diff == 1:
    ans = math.factorial(max(n,m))
    print((ans*(ans//max(n,m))%(10**9+7)))
else:
    ans = math.factorial(n)
    print((ans*ans*2%(10**9+7)))
# Original solution
N,M = list(map(int,input().split()))

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

L = 0
if N == M:
    cnt = 1
    for i in range(1,N+1):
        cnt *= i
    ccnt = cnt
else:
    mi = min([N,M])
    ma = max([N,M])
    cnt = 1
    for i in range(1,mi+1):
        cnt *= i

    ccnt = cnt * ma


nn = N%2
mm = M%2
if (nn == 0 and mm == 0) or (nn == 1 and mm == 1):
    print(((cnt * ccnt * 2) % 1000000007))
else:
    print(((cnt * ccnt) % 1000000007))


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

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

L = 0
if N == M:
    cnt = 1
    for i in range(1,N+1):
        cnt *= i
        cnt %= 1000000007
    ccnt = cnt
else:
    mi = min([N,M])
    ma = max([N,M])
    cnt = 1
    for i in range(1,mi+1):
        cnt *= i
        cnt %= 1000000007

    ccnt = cnt * ma


nn = N%2
mm = M%2
if (nn == 0 and mm == 0) or (nn == 1 and mm == 1):
    print(((cnt * ccnt * 2) % 1000000007))
else:
    print(((cnt * ccnt) % 1000000007))
# Original solution
p = 10**9+7
N,M = list(map(int,input().split()))
a = 1
for i in range(2,N+1):
    a = (a*i)%p
b = 1
for i in range(2,M+1):
    b = (b*i)%p
if M==N:
    n = (2*a*b)%p
elif M==N-1 or N==M-1:
    n = (a*b)%p
else:
    n = 0
print(n)

# Optimized solution
p = 10**9+7
N,M = list(map(int,input().split()))
A = [1 for _ in range(N+1)]
for i in range(2,N+1):
    A[i] = (i*A[i-1])%p
B = [1 for _ in range(M+1)]
for i in range(2,M+1):
    B[i] = (i*B[i-1])%p
if abs(N-M)>1:
    ans = 0
elif abs(N-M)==1:
    ans = (A[N]*B[M])%p
elif abs(N-M)==0:
    ans = (2*A[N]*B[M])%p
print(ans)
# Original solution
import math

nm = input().split(" ");
n = int(nm[0]);
m = int(nm[1]);
if n - m == 1 or m - n == 1:
  ansn = math.factorial(n);
  ansm = math.factorial(m);
  print((ansn*ansm));
elif n == m :
  ansn = math.factorial(n);
  ansm = math.factorial(m);
  print((ansn*ansm*2));
else :
  print((0));

# Optimized solution
nm = input().split(" ");
n = int(nm[0]);
m = int(nm[1]);
mod = 10**9+7
if n - m == 1 or m - n == 1:
	ansn = 1;
	for i in range(n) :
		ansn = (ansn % mod)*((n-i) % mod);
		ansm = 1;
	for j in range(m) :
	 	ansm = (ansm % mod)*((m-j) % mod);
	print(((ansn*ansm) % mod));
elif n == m :
	ansn = 1;
	for i in range(n) :
		ansn = (ansn % mod)*((n-i) % mod);
		ansm = 1;
	for j in range(m) :
  		ansm = (ansm % mod)*((m-j) % mod);
	print(((ansn*ansm*2) % mod));
else :
	print((0));
# Original solution
def Factorial(A):
    X = 1
    for num in range(1, A+1):
        X *= num
    return X

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

if n == m+1:
    ans = Factorial(n)*Factorial(m)
elif n == m:
    ans = Factorial(n)*Factorial(m)*2
elif n+1 == m:
    ans = Factorial(n)*Factorial(m)
else:
    ans = 0
print(ans)

# Optimized solution
def Factorial(A):
    MOD = 10**9+7
    X = 1
    for num in range(1, A+1):
        X *= num
        X %= MOD
    return X

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

if n == m+1:
    ans = Factorial(n)*Factorial(m)
elif n == m:
    ans = Factorial(n)*Factorial(m)*2
elif n+1 == m:
    ans = Factorial(n)*Factorial(m)
else:
    ans = 0
print((ans%MOD))
# Original solution
import sys
import collections
sys.setrecursionlimit(100000)
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: list(map(int, sys.stdin.readline().split()))
nl = lambda: list(nm())
nsl = lambda: list(map(str, sys.stdin.readline().split()))

n, m = nm()
memo = [-1 for i in range(max(n, m) + 1)]
mod = 10 ** 9 + 7

for i in range(1, max(n, m) + 1):
    if memo[i] != -1:
        continue
    elif i == 1:
        memo[i] = 1
    else:
        memo[i] = i * memo[i - 1]

if abs(n - m) >= 2:
    print((0))
else:
    nn = memo[n] % mod
    mm = memo[m] % mod
    if n == m:
        print((2 * nn * mm % mod))
    else:
        print((nn * mm % mod))


# Optimized solution
import sys
import collections
sys.setrecursionlimit(100000)
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: list(map(int, sys.stdin.readline().split()))
nl = lambda: list(nm())
nsl = lambda: list(map(str, sys.stdin.readline().split()))

n, m = nm()
memo = [1 for _ in range(max(n, m) + 1)]
mod = 10 ** 9 + 7

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

if abs(n - m) >= 2:
    print((0))
else:
    nn = memo[n] % mod
    mm = memo[m] % mod
    if n == m:
        print((2 * nn * mm % mod))
    else:
        print((nn * mm % mod))
# Original solution
N,M=list(map(int,input().split()))
total=1
mod=1000000007
if N==M:
    for i in range(1,N+1):
        total=total*i*i
    print(((total*2)%mod))

elif N+1==M or M+1==N:
    total*=max(M,N)
    for i in range(1,min(M,N)+1):
        total=total*i*i
    print((total%mod))
else:
    print((0))

# Optimized solution
N,M=list(map(int,input().split()))
total=1
mod=1000000007
if N==M:
    for i in range(1,N+1):
        total=total*i*i
        total=total%mod
    print(((total*2)%mod))

elif N+1==M or M+1==N:
    total*=max(M,N)
    for i in range(1,min(M,N)+1):
        total=total*i*i
        total=total%mod
    print((total%mod))
else:
    print((0))
# Original solution
# -*- coding: utf-8 -*-
import math
n,m = list(map(int, input().split()))
mod = 10**9+7
if(n==m):
    print(((2*(math.factorial(n))**2)%mod))
elif(abs(n-m)==1):
    tmp = math.factorial(min(n,m))
    print((max(n,m)*(tmp**2)%mod))
else:
    print((0))

# Optimized solution
# -*- coding: utf-8 -*-
def fact(x):
    f = 1
    for i in range(1,x+1):
        f *= i
        f %= 10**9+7
    return f             

n,m = list(map(int, input().split()))
mod = 10**9+7
if(n==m):
    print(((2*(fact(n))**2)%mod))
elif(abs(n-m)==1):
    tmp = fact(min(n,m))
    print((max(n,m)*(tmp**2)%mod))
else:
    print((0))
# Original solution
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
n,m = list(map(int,input().split()))
if n == m:
    ans = P(n,n) * P(m,m) * 2
    print(ans)
elif abs(n-m) > 1:
    print((0))
else:
    ans = P(n,n)*P(m,m)
    print(ans)

# Optimized solution
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
n,m = list(map(int,input().split()))
mod = 10**9+7
if n == m:
    ans = P(n,n) * P(m,m) * 2
    print((ans%mod))
elif abs(n-m) > 1:
    print((0))
else:
    ans = P(n,n)*P(m,m)
    print((ans%mod))
# Original solution
from math import factorial as f
n, m = list(map(int, input().split()))
mod = 10 ** 9 + 7
if abs(n - m) == 1:
    res = f(n) * f(m)
    print((res % mod))
elif n == m:
    res = f(n) * f(m) * 2
    print((res % mod))
else:
    print((0))


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


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


pn = permitation(n)
pm = permitation(m)

if n == m:
    res = pn * pm * 2 % mod
    print(res)
elif n == m - 1 or n == m + 1:
    res = pn * pm % mod
    print(res)
else:
    print((0))
# Original solution
n,m=list(map(int,input().split()))
mod=10**9+7
if abs(n-m)>1:
    print((0))
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a*=i%mod
if n!=m:
    b*=max(n,m)*a
    print(((a*b)%mod))
else:
    b=a
    print(((2*a*b)%mod))

# Optimized solution
n,m=list(map(int,input().split()))
mod=10**9+7
if abs(n-m)>1:
    print((0))
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a=(a*i)%mod
if n!=m:
    b*=max(n,m)*a
    print(((a*b)%mod))
else:
    b=a
    print(((2*a*b)%mod))
# Original solution
from itertools import permutations
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
p_n = len(list(permutations(i for i in range(N))))
p_m = len(list(permutations(i for i in range(M))))
if abs(N-M)==0:
    print((2*p_n*p_m))
elif abs(N-M)==1:
    print((p_n*p_m))
else:
    print((0))

# Optimized solution
from math import factorial
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
p_n = factorial(N)
p_m = factorial(M)
NUM = 10**9+7
if abs(N-M)==0:
    ans = 2*p_n*p_m
elif abs(N-M)==1:
    ans = p_n*p_m
else:
    ans = 0
print((ans%NUM))
# Original solution
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



D = 10**9+7

def main():
  NM = sorted(list(map(int, input().split())))
  if NM[1]-NM[0] > 1:
    return 0
  elif NM[0]==NM[1]:
    ret = 2*(math.factorial(NM[0])**2) % D
    return ret
  else:
    ret = math.factorial(NM[0])*math.factorial(NM[1])
    return ret

if __name__ == "__main__":
  print((main()))

# Optimized solution
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



D = 10**9+7

def main():
  NM = sorted(list(map(int, input().split())))
  if NM[1]-NM[0] > 1:
    return 0
  elif NM[0]==NM[1]:
    ret = 2*(math.factorial(NM[0])**2) % D
    return ret
  else:
    ret = math.factorial(NM[0])*math.factorial(NM[1]) % D
    return ret

if __name__ == "__main__":
  print((main()))
# Original solution
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



D = 10**9+7

def main():
  NM = sorted(list(map(int, input().split())))
  if NM[1]-NM[0] > 1:
    return 0
  elif NM[0]==NM[1]:
    ret = 2*(math.factorial(NM[0])**2) % D
    return ret
  else:
    ret = math.factorial(NM[0])*math.factorial(NM[1]) % D
    return ret

if __name__ == "__main__":
  print((main()))

# Optimized solution
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



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


def main():
  NM = sorted(list(map(int, input().split())))
  n,m = [fact(NM[0]), fact(NM[1])]
  if NM[0]==NM[1]:
    return (n*m*2) % D
  elif NM[0]+1==NM[1]:
    return (n*m) % D
  else:
    return 0

if __name__ == "__main__":
  print((main()))
# Original solution
import math
n = sorted(list(map(int,input().split())))
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = math.factorial(n[1]) **2 * 2
else:
    ans = math.factorial(n[1]) * math.factorial(n[0])
print((ans % (10**9 + 7) ))



# Optimized solution
import math
n = sorted(list(map(int,input().split())))
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = math.factorial(n[1]) **2 * 2
else:
    ans = n[1] * math.factorial(n[0])**2
print((ans % (10**9 + 7) ))
# Original solution
import math
n = sorted(list(map(int,input().split())))
n[1] %= (10**9 + 7)
n[0] %= (10**9 + 7)
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = math.factorial(n[1]) **2 * 2
else:
    ans = n[1] * math.factorial(n[0])**2
print((ans % (10**9 + 7) ))

# Optimized solution
import math
n = sorted(list(map(int,input().split())))
n[1] %= (10**9 + 7)
n[0] %= (10**9 + 7)
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = (math.factorial(n[1])%(10**9 + 7)) **2 * 2
else:
    ans = n[1] * (math.factorial(n[0]) % (10**9 + 7))**2
print((ans % (10**9 + 7) ))
# Original solution
from math import factorial as f
N,M = list(map(int,input().split()))
print((max(0,2-abs(N-M))*f(N)*f(M)%(10**9+7)))

# Optimized solution
from math import *
N,M = list(map(int,input().split()))

if abs(N-M)==0:
  ans = 2*factorial(N)*factorial(M)
elif abs(N-M)==1:
  ans = factorial(N)*factorial(M)
else:
  ans = 0

print((ans%(10**9+7)))
# Original solution
from math import factorial
n,m=list(map(int,input().split()))
if n==m:
    print((2*factorial(n)*factorial(m)))
elif n==m+1 or m==n+1:
        print((factorial(n)*factorial(m)))
else:
    print((0))
    

# Optimized solution
import sys
sys.setrecursionlimit(10**7)
n,m=list(map(int,input().split()))
def fact(n):
    mod=10**9+7
    if n==0:
        return 1
    else:
        return (n*fact(n-1))%mod
mod=10**9+7
if n==m:
    print((2*fact(n)*fact(m)%mod))
elif n==m+1 or m==n+1:
        print((fact(n)*fact(m)%mod))
else:
    print((0))
# Original solution
N,M=list(map(int,input().split()))

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
n = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p) 階乗のmod
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans=(fact[N]*fact[M])%p
if N==M:
    ans*=2
    ans%=p
print(ans)

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

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

p = 10 ** 9 + 7
n = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p) 階乗のmod
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

if N==M:
    ans=2*fact[N]*fact[M] % p
else:
    big = max(N, M)
    small = min(N, M)
    ans = fact[N]*fact[M] % p

print(ans)
# Original solution
n, m = list(map(int, input().split()))
INF = 10**9+7

if abs(n-m) > 1:
    print((0))
else:
    nf = 1
    for i in range(1, n+1):
        nf *= i
        nf %= INF

    mf = 1
    for i in range(1, m+1):
        mf *= i
        mf %= INF

    if n == m:
        print((nf * mf * 2 % INF))
    else:
        print((nf * mf % INF))

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

if abs(n-m) > 1:
    print((0))
else:
    nf, mf = 1, 1
    for i in range(1, min(n, m)+1):
        nf = (nf*i) % MOD

    if n != m:
        mf = max(n, m) * nf
    else:
        mf = nf

    if n == m:
        print((nf * mf * 2 % MOD))
    else:
        print((nf * mf % MOD))
# Original solution
import math as m
a,b=list(map(int,input().split()))
print((m.factorial(a)*m.factorial(b)*[1,2][a==b] if -2<a-b<2 else 0))

# Optimized solution
m=1000000007
f=lambda j,k:(j%m)*(k%m)%m
a,b=sorted(map(int,input().split()))
x=1
for i in range(2,a+1):
  x=f(x,i)
print((f(f(x,[x*b,x][a==b]),[1,2][a==b]) if b-a<2 else 0))
# Original solution
from functools import reduce
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    FCT = reduce(modmulti, list(range(2, x + 1)), FCT)
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M or N + 1 == M or N == M + 1:
        print((modmulti(2, modmulti(MIN_NM, MIN_NM))
              if N == M else modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))
    else:
        print((0))

    return


main()


# Optimized solution
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = modmulti(i, FCT)
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M or N + 1 == M or N == M + 1:
        print((modmulti(2, modmulti(MIN_NM, MIN_NM))
              if N == M else modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))
    else:
        print((0))

    return


main()
# Original solution
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = modmulti(i, FCT)
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M or N + 1 == M or N == M + 1:
        print((modmulti(2, modmulti(MIN_NM, MIN_NM))
              if N == M else modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))
    else:
        print((0))

    return


main()


# Optimized solution
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = modmulti(i, FCT)
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M:
        print((modmulti(2, modmulti(MIN_NM, MIN_NM))))
    elif abs(N - M) <= 1:
        print((modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))
    else:
        print((0))

    return


main()
# Original solution
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = modmulti(i, FCT)
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M:
        print((modmulti(2, modmulti(MIN_NM, MIN_NM))))
    elif abs(N - M) <= 1:
        print((modmulti(MIN_NM, modmulti(MIN_NM, max(N, M)))))
    else:
        print((0))

    return


main()


# Optimized solution
INF = int(1e9 + 7)


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = i * FCT % INF
    return FCT


def main():
    N, M = list(map(int, input().split()))
    MIN_NM = factorial(min(N, M))
    if N == M:
        print((2 * MIN_NM * MIN_NM % INF))
    elif abs(N - M) <= 1:
        print((MIN_NM * MIN_NM * max(N, M) % INF))
    else:
        print((0))

    return


main()
# Original solution
def f(x):
    k = 1
    for i in range(1,x+1):
        k *= i
    return k % (10**9 + 7)

a,b = list(map(int,input().split()))

if abs(a-b) <= 1:
    print(((f(a)*f(b)) % (10**9 + 7) if abs(a-b) == 1 else (2*f(a)*f(b)) % (10**9 + 7)))
else:
    print((0))

# Optimized solution
import math
def f(x):
    return math.factorial(x) % (10**9 + 7)

a,b = list(map(int,input().split()))

if abs(a-b) <= 1:
    print(((f(a)*f(b)) % (10**9 + 7) if abs(a-b) == 1 else (2*f(a)*f(b)) % (10**9 + 7)))
else:
    print((0))
# Original solution
n, m = list(map(int, input().split()))
mod = 10**9 + 7
def fact(n):
  i = n
  ret = 1
  while i > 1:
    ret *= i
    i -= 1
  return ret
if n == m:
  print((fact(n) ** 2 * 2 % mod))
# elif n+1 == m or n-1 == m:
#   print(fact(n) * fact(m))
elif n == m+1:
  n_f = fact(n)
  print((n_f * (n_f//n) % mod))
elif n == m-1:
  m_f = fact(m)
  print((m_f * (m_f//m) % mod))
else:
  print((0))

# Optimized solution
n, m = list(map(int, input().split()))
mod = 10**9 + 7
def fact(x):
  ret = 1
  for i in range(1, x+1):
    ret = ret * i % mod
  return ret
if n == m:
  print((fact(n)**2 * 2 % mod))
elif n+1 == m or n-1 == m:
  print((fact(n) * fact(m) % mod))
else:
  print((0))