Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 ≤ N,M ≤ 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.

# Buggy version:
n,m = map(int,input().split())
lim = int(1e+9+7)


def pat(r,t = lim):
    ans = 1
    for i in range(r):
        ans = (ans*(i+1))%t
    return ans%t

a = pat(n)
b = pat(m)

if abs(n-m) < 2:
    print((a*b*2)%lim)
elif abs(n-m) == 2:
    print((a*b)%lim)
else:
    print(0)

# Fixed version:
n,m = map(int,input().split())
lim = int(1e+9+7)


def pat(r,t = lim):
    ans = 1
    for i in range(r):
        ans = (ans*(i+1))%t
    return ans%t

a = pat(n)
b = pat(m)

if abs(n-m) < 1:
    print((a*b*2)%lim)
elif abs(n-m) == 1:
    print((a*b)%lim)
else:
    print(0)

# Buggy version:
###ncrのmodあまりの話
mod=10**9+7
N=100005
kaidan=[1 for i in range(N)]
gyaku=[1 for i in range(N)]
for i in range(1,N):
    kaidan[i] = (i * kaidan[i-1])%mod
    gyaku[i]=pow(bikkuri[i], mod-2, mod)
def comb(a,b):
    return kaidan[a]*gyaku[b]*gyaku[a-b]
n,m=map(int,input().split())
if abs(n-m)>=2:
    print(0)
else:
    if n==m:
        print(kaidan[n]*kaidan[n]*2%mod)
    else:
        a=max(n,m)
        b=min(n,m)
        print(kaidan[a]*kaidan[b]%mod)

# Fixed version:
###ncrのmodあまりの話
mod=10**9+7
N=100005
kaidan=[1 for i in range(N)]
gyaku=[1 for i in range(N)]
for i in range(1,N):
    kaidan[i] = (i * kaidan[i-1])%mod
    gyaku[i]=pow(kaidan[i], mod-2, mod)
def comb(a,b):
    return kaidan[a]*gyaku[b]*gyaku[a-b]
n,m=map(int,input().split())
if abs(n-m)>=2:
    print(0)
else:
    if n==m:
        print(kaidan[n]*kaidan[n]*2%mod)
    else:
        a=max(n,m)
        b=min(n,m)
        print(kaidan[a]*kaidan[b]%mod)

# Buggy version:
import sys
from functools import reduce,lru_cache
from operator import mul

def main():
  sys.setrecursionlimit(10 ** 5)
  N,M = map(int,input().split())
  
  @lru_cache(maxsize = None)
  def recur(n):
    if n == 0:
      return 1
    else:
      m = n * recur(n - 1)
      return m
      
  if N == M:
    L = [i for i in range(1,N + 1)]
    #ans = (reduce(mul,L) ** 2) * 2  % (10 ** 9 + 7)
    ans = (recur(N) % (10 ** 9 + 7))
    print(ans)
  elif abs(M - N) == 1: 
    ans = 1
    ans *= (recur(N) % (10 ** 9 + 7)) 
    ans *= (recur(M) % (10 ** 9 + 7))
    print(ans)
    
  else:
    print(0)
    
main()

# Fixed version:
import sys
from functools import reduce,lru_cache
import math
from operator import mul

def main():
  #sys.setrecursionlimit(10 ** 5 + 1)
  N,M = map(int,input().split())
  
  @lru_cache(maxsize = None)
  def recur(n):
    if n == 0:
      return 1
    else:
      m = n * recur(n - 1)
      return m
      
  if N == M:
    L = [i for i in range(1,N + 1)]
    #ans = (reduce(mul,L) ** 2) * 2  % (10 ** 9 + 7)
    ans = (math.factorial(M) ** 2) * 2 % ((10 ** 9) + 7)
    print(ans)
  elif abs(M - N) == 1: 
    ans = math.factorial(N) * math.factorial(M) % ((10 ** 9) + 7)
    print(ans)
    
  else:
    print(0)
    
main()

# Buggy version:
# ARC076C - Reconciled?
def factorial(x):
    ret = 1
    for i in range(1, x + 1):
        ret *= i
    return ret


def main():
    n, m = list(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    dif = abs(n - m)
    if dif > 1:  # must be ...DDM...
        print(0)
    else:
        if dif == 0:  # start with either D or M (DM..., MD...)
            ans = (factorial(n) * factorial(m) * 2) % MOD
        else:  # sandwich (DMD or MDM)
            ans = (factorial(n) * factorial(m)) % MOD
        print(ans)


if __name__ == "__main__":
    main()

# Fixed version:
# ARC076C - Reconciled?
def factorial_mod(x):
    MOD = 10 ** 9 + 7
    ret = 1
    for i in range(1, x + 1):
        ret = (ret * i) % MOD
    return ret


def main():
    n, m = list(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    n, m = min(n, m), max(n, m)
    dif = m - n
    if dif > 1:  # must be ...DDM...
        print(0)
    else:
        if dif == 0:  # start with either D or M (DM..., MD...)
            ans = (factorial_mod(n) ** 2 * 2) % MOD
        else:  # sandwich (DMD or MDM)
            ans = (factorial_mod(n) ** 2 * m) % MOD
        print(ans)


if __name__ == "__main__":
    main()

# Buggy version:
# ARC076C - Reconciled?
from math import factorial


def main():
    n, m = list(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    if abs(n - m) not in (0, 1):
        print(0)
    else:
        ans = (factorial(n) * factorial(m) * 2) % MOD
        print(ans)


if __name__ == "__main__":
    main()

# Fixed version:
# ARC076C - Reconciled?
from math import factorial


def main():
    n, m = list(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    dif = abs(n - m)
    if abs(n - m) not in (0, 1):
        print(0)
    else:
        if dif == 0:
            ans = (factorial(n) * factorial(m) * 2) % MOD
        else:
            ans = (factorial(n) * factorial(m)) % MOD
        print(ans)


if __name__ == "__main__":
    main()

# Buggy version:
n, m = map(int, input().split())
a = 0
b = 0
if abs(n-m) >= 2:
    print(0)
else:
    for i in range(2, n+1):
        a = (a*i) % (10**9+7)
    for j in range(2, m+1):
        b = (b*j) % (10**9+7)
    if n == m:
        print((a*b*2) % (10**9+7))
    else:
        print((a*b) % (10**9+7))


# Fixed version:
n, m = map(int, input().split())
a = 1
b = 1
if abs(n-m) >= 2:
    print(0)
else:
    for i in range(2, n+1):
        a = (a*i) % (10**9+7)
    for j in range(2, m+1):
        b = (b*j) % (10**9+7)
    if n == m:
        print((a*b*2) % (10**9+7))
    else:
        print((a*b) % (10**9+7))

# Buggy version:
a,b = map(int,input().split(" "))
c = 1
d = 1
for i in range(2,a+1):
    c *= i % (10 ** 9 + 7)
for i in range(2,b+1):
    d *= i % (10 ** 9 + 7)
if abs(a - b) >= 2:
    print(0)
elif a == b:
    print(((c * d) * 2) % (10 ** 9 + 7))
else:
    print((c * d) % (10 ** 9 + 7))

# Fixed version:
a,b = map(int,input().split(" "))
c = 1
d = 1
for i in range(2,a+1):
    c = (c * i) % (10 ** 9 + 7)
for i in range(2,b+1):
    d = (d * i) % (10 ** 9 + 7)
if abs(a - b) >= 2:
    print(0)
elif a == b:
    print(((c * d) * 2) % (10 ** 9 + 7))
else:
    print((c * d) % (10 ** 9 + 7))

# Buggy version:
import math
N,M = map(int,input().split())
if abs(N - M) > 1:
  print(0)
else:
  print((math.factorial(N) * math.factorial(M)) % 1000000007)

# Fixed version:
import math
N,M = map(int,input().split())
if abs(N - M) > 1:
  print(0)
elif N == M:
  print((2*(math.factorial(N) * math.factorial(M))) % 1000000007)
else:
  print(((math.factorial(N) * math.factorial(M))) % 1000000007)

# Buggy version:
n,m = map(int,input().split())
if abs(n - m) >= 2:
  print("0")
else:
  cou = 2
  while n > 1:
    cou *= n
    cou %= (10 ** 9 + 7)
    n -= 1
  while m > 1:
    cou *= m
    cou %= (10 ** 9 + 7)
    m -= 1
print(cou)

# Fixed version:
n,m = map(int,input().split())
if abs(n - m) >= 2:
  print("0")
else:
  if n == m:cou = 2
  else:cou = 1
  while n > 1:
    cou *= n
    cou %= (10 ** 9 + 7)
    n -= 1
  while m > 1:
    cou *= m
    cou %= (10 ** 9 + 7)
    m -= 1
  print(cou)

# Buggy version:
import math
N,M = map(int,input().split())
if abs(N - M) > 1:
  print(0)
else:
  print((2*(math.factorial(N) * math.factorial(M))) % 1000000007)

# Fixed version:
import math
PRIME_NUM = 1000000007
N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
elif N == M:
    print(2 * (math.factorial(N) % PRIME_NUM) * (math.factorial(M) % PRIME_NUM) % PRIME_NUM)
else:
    print((math.factorial(N) % PRIME_NUM) * (math.factorial(M) % PRIME_NUM) % PRIME_NUM)

# Buggy version:
N, M = map(int, input().split())
# N, M = 100000, 100000

mod = 10 ** 9 + 7
if N < M:
    N, M = M, N

if M - N >= 2:
    print(0)
elif M - N == 1:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print((prod * prod * M) % mod)
else:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print((2 * prod * prod) % mod)


# Fixed version:

N, M = map(int, input().split())
# N, M = 100000, 100000

mod = 10 ** 9 + 7
if N > M:
    N, M = M, N

if M - N >= 2:
    print(0)
elif M - N == 1:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print((prod * prod * M) % mod)
else:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print((2 * prod * prod) % mod)

# Buggy version:
import sys
import math
n, m = (int(i) for i in input().split())
l=abs(n-m)
div=int(10e9+7)

if l>1:
    print(0)
    sys.exit()

if l==1:
    ans=(math.factorial(n)*math.factorial(m))%div
    print(ans)
else:
    ans=(math.factorial(n)*math.factorial(m)*2)%div
    print(ans)


# Fixed version:
import sys
import math
n, m = (int(i) for i in input().split())
l=abs(n-m)
div=int(10**9+7)

if l>1:
    print(0)
    sys.exit()

if l==1:
    ans=(math.factorial(n)*math.factorial(m))%div
    print(ans)
else:
    ans=(math.factorial(n)*math.factorial(m)*2)%div
    print(ans)

# Buggy version:
#encoding: utf-8

def main():
    N,M=map(int,input().split())
    if(abs(N-M)>=2):
        print(0)
        return 

    ret=1
    mod=10**9+7
    for i in range(1,N+1):
        ret*=i
        ret%=mod
    for i in range(1,M+1):
        ret*=i
        ret %= mod
    print(ret*2)


if __name__ == '__main__':
    main()

# Fixed version:
#encoding: utf-8

def main():
    N,M=map(int,input().split())
    if(abs(N-M)>=2):
        print(0)
        return

    ret=1
    mod=10**9+7
    for i in range(1,N+1):
        ret*=i
        ret%=mod
    for i in range(1,M+1):
        ret*=i
        ret %= mod
    if(N==M):
        r=2
    else:
        r=1
    print((ret*r)%mod)


if __name__ == '__main__':
    main()

# Buggy version:
dog_ape = list(map(int,input().split(" ")))
dog_ape.sort()
cut     = (10**9)+7

def kai(n):
    ans = 1
    r   = 0
    for i in range(n):
        ans *= (i+1)**2
    return ans

if dog_ape[0] == dog_ape[1]:
    ans = ( kai(dog_ape[0]) )*2
    ans %= cut
    print(ans)

elif dog_ape[1] - dog_ape[0] == 1:
    ans = kai(dog_ape[0])*(dog_ape[1])
    ans %= cut
    print(ans)

else:
    print(0)  


# Fixed version:
dog_ape = list(map(int,input().split(" ")))
dog_ape.sort()
cut     = (10**9)+7

def kai(n):
    ans = 1
    r   = 0
    for i in range(n):
        ans *= (i+1)**2
        if ans > cut:
            ans %= cut
    return ans

if dog_ape[0] == dog_ape[1]:
    ans = ( kai(dog_ape[0]) )*2
    ans %= cut
    print(ans)

elif dog_ape[1] - dog_ape[0] == 1:
    ans = kai(dog_ape[0])*(dog_ape[1])
    ans %= cut
    print(ans)

else:
    print(0)

# Buggy version:
import math
import sys

a = sys.stdin.readline().split(' ')
n = int(a[0])
m = int(a[1])

modulator = 1000000007

if n == m:
	print((math.factorial(n) * math.factorial(m) * 2) % modulator)
elif abs(n - m) == 1 :
	print((math.factorial(n) * math.factorial(n)) % modulator)
else:
	print(0)


# Fixed version:
import math
import sys

a = sys.stdin.readline().split(' ')
n = int(a[0])
m = int(a[1])

modulator = 1000000007

if n == m:
	print((math.factorial(n) * math.factorial(m) * 2) % modulator)
elif abs(n - m) == 1 :
	print((math.factorial(n) * math.factorial(m)) % modulator)
else:
	print(0)

# Buggy version:
def Factorial(integer) :
    global M

    product = 1
    if integer == 0 : return 1
    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorialo(d[0])

print(res%(10**9+7))

# Fixed version:

def Factorial(integer) :
    global M
    product = 1
    if integer == 0 : return 1

    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product%M


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorial(d[0])

print(res%(M))

# Buggy version:
from math import factorial

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

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)+tm)

	elif N==M:
		return(2*factorial(N)*2)

	else:
		return(0)

print(foo(N,M)/(10**9+7))

# Fixed version:
from math import factorial

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

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)*tm)

	elif N==M:
		return((factorial(N)**2)*2)

	else:
		return(0)

print(foo(N,M)%(10**9+7))