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

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

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

-import math as m +N, M = list(map(int, input().split())) +MOD = 10**9 + 7 -N, M = list(map(int, input().split())) + +def permutation(n): +    res = 1 +    for i in range(1, n + 1): +        res = (res * i) % MOD +    return res + + -    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))) +    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))