import numpy as np

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

if abs(n - m) > 1:

  print((0))

  quit()

mod = 10 ** 9 + 7





def cumprod(L, mod=mod):

    A = np.arange(L, dtype=np.int64)

    A[0] = 1

    Lsq = int(L**.5 + 1)

    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)

    for n in range(1, Lsq):

        A[:, n] *= A[:, n - 1]

        A[:, n] %= mod

    for n in range(1, Lsq):

        A[n] *= A[n - 1, -1]

        A[n] %= mod

    return A.ravel()[:L]





fact = cumprod(2 * 10**6 + 10, mod)

res = fact[n] * fact[m]

if n == m:

  res *= 2

print((res % mod))
n, m = list(map(int, input().split()))

mod = 10 ** 9 + 7

n, m = max(n, m), min(n, m)

if n - m > 1:

  print((0))

  quit()

res = 1

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

  res *= i

  res %= mod

if n - m:

  res *= res * n

else:

  res *= res * 2

print((res % mod))
import numpy as np

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


def cumprod(L, mod=mod):
    A = np.arange(L, dtype=np.int64)
    A[0] = 1
    Lsq = int(L**0.5 + 1)
    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        A[:, n] *= A[:, n - 1]
        A[:, n] %= mod
    for n in range(1, Lsq):
        A[n] *= A[n - 1, -1]
        A[n] %= mod
    return A.ravel()[:L]


fact = cumprod(2 * 10**6 + 10, mod)
res = fact[n] * fact[m]
if n == m:
    res *= 2
print((res % mod))

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

-import numpy as np - -if abs(n - m) > 1: +mod = 10**9 + 7 +n, m = max(n, m), min(n, m) +if n - m > 1: -mod = 10**9 + 7 - - -def cumprod(L, mod=mod): -    A = np.arange(L, dtype=np.int64) -    A[0] = 1 -    Lsq = int(L**0.5 + 1) -    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq) -    for n in range(1, Lsq): -        A[:, n] *= A[:, n - 1] -        A[:, n] %= mod -    for n in range(1, Lsq): -        A[n] *= A[n - 1, -1] -        A[n] %= mod -    return A.ravel()[:L] - - -fact = cumprod(2 * 10**6 + 10, mod) -res = fact[n] * fact[m] -if n == m: -    res *= 2 +res = 1 +for i in range(1, m + 1): +    res *= i +    res %= mod +if n - m: +    res *= res * n +else: +    res *= res * 2