import sys



def permutation(n, x, mod=10**9+7):

    # nPx

    # 順列

    # ex) permutaion(5, 2) = 20

    tmp = 1

    for i in range(n, n-x, -1):

        tmp = (tmp * i) % mod

    return tmp



N, M = list(map(int, sys.stdin.readline().strip().split()))



if abs(N - M) > 1:

    print((0))

elif abs(N - M) == 1:

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

else:

    print((2 * permutation(N, N) * permutation(M, M)  % (10**9+7)))
import sys

import math



mod = 10**9 + 7

N, M = list(map(int, sys.stdin.readline().split()))

diff = abs(N - M)

if diff > 1:

    print((0))

    sys.exit()



n_p = 1

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

    n_p *= i

    n_p %= mod

m_p = 1

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

    m_p *= i

    m_p %= mod



if diff == 0:

    print((2 * n_p * m_p % mod))

else:

    print((n_p * m_p % mod))
import sys


def permutation(n, x, mod=10**9 + 7):
    # nPx
    # 順列
    # ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n - x, -1):
        tmp = (tmp * i) % mod
    return tmp


N, M = list(map(int, sys.stdin.readline().strip().split()))
if abs(N - M) > 1:
    print((0))
elif abs(N - M) == 1:
    print((permutation(N, N) * permutation(M, M) % (10**9 + 7)))
else:
    print((2 * permutation(N, N) * permutation(M, M) % (10**9 + 7)))

import sys
import math

mod = 10**9 + 7
N, M = list(map(int, sys.stdin.readline().split()))
diff = abs(N - M)
if diff > 1:
    print((0))
    sys.exit()
n_p = 1
for i in range(1, N + 1):
    n_p *= i
    n_p %= mod
m_p = 1
for i in range(1, M + 1):
    m_p *= i
    m_p %= mod
if diff == 0:
    print((2 * n_p * m_p % mod))
else:
    print((n_p * m_p % mod))

+import math - -def permutation(n, x, mod=10**9 + 7): -    # nPx -    # 順列 -    # ex) permutaion(5, 2) = 20 -    tmp = 1 -    for i in range(n, n - x, -1): -        tmp = (tmp * i) % mod -    return tmp - - -N, M = list(map(int, sys.stdin.readline().strip().split())) -if abs(N - M) > 1: +mod = 10**9 + 7 +N, M = list(map(int, sys.stdin.readline().split())) +diff = abs(N - M) +if diff > 1: -elif abs(N - M) == 1: -    print((permutation(N, N) * permutation(M, M) % (10**9 + 7))) +    sys.exit() +n_p = 1 +for i in range(1, N + 1): +    n_p *= i +    n_p %= mod +m_p = 1 +for i in range(1, M + 1): +    m_p *= i +    m_p %= mod +if diff == 0: +    print((2 * n_p * m_p % mod)) -    print((2 * permutation(N, N) * permutation(M, M) % (10**9 + 7))) +    print((n_p * m_p % mod))