import math



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

if abs(n-m) > 1:

	print((0))

	exit()

s = 2 if n == m else 1

np = math.factorial(n)

mp = math.factorial(m)

r = (mp*np*s) % (10**9 + 7)

print(r)
def test():

	mod = 10**9 + 7

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

	if abs(n-m) > 1:

		print((0))

		exit()

	i_n = n

	i_m = m

	np = 1

	mp = 1

	while True:

		np = (np%mod) * (i_n%mod)

		mp = (mp%mod) * (i_m%mod)

		i_n -= 1

		i_m -= 1

		if i_n < 1:

			i_n = 1

		if i_m < 1:

			i_m = 1

		if i_n == 1 and i_m == 1:

			break

	s = 2 if n == m else 1

	r = (mp*np*s) % (10**9 + 7)

	print(r)

test()
import math

n, m = list(map(int, input().split()))
if abs(n - m) > 1:
    print((0))
    exit()
s = 2 if n == m else 1
np = math.factorial(n)
mp = math.factorial(m)
r = (mp * np * s) % (10**9 + 7)
print(r)

def test():
    mod = 10**9 + 7
    n, m = list(map(int, input().split()))
    if abs(n - m) > 1:
        print((0))
        exit()
    i_n = n
    i_m = m
    np = 1
    mp = 1
    while True:
        np = (np % mod) * (i_n % mod)
        mp = (mp % mod) * (i_m % mod)
        i_n -= 1
        i_m -= 1
        if i_n < 1:
            i_n = 1
        if i_m < 1:
            i_m = 1
        if i_n == 1 and i_m == 1:
            break
    s = 2 if n == m else 1
    r = (mp * np * s) % (10**9 + 7)
    print(r)


test()

-import math +def test(): +    mod = 10**9 + 7 +    n, m = list(map(int, input().split())) +    if abs(n - m) > 1: +        print((0)) +        exit() +    i_n = n +    i_m = m +    np = 1 +    mp = 1 +    while True: +        np = (np % mod) * (i_n % mod) +        mp = (mp % mod) * (i_m % mod) +        i_n -= 1 +        i_m -= 1 +        if i_n < 1: +            i_n = 1 +        if i_m < 1: +            i_m = 1 +        if i_n == 1 and i_m == 1: +            break +    s = 2 if n == m else 1 +    r = (mp * np * s) % (10**9 + 7) +    print(r) -n, m = list(map(int, input().split())) -if abs(n - m) > 1: -    print((0)) -    exit() -s = 2 if n == m else 1 -np = math.factorial(n) -mp = math.factorial(m) -r = (mp * np * s) % (10**9 + 7) -print(r) + +test()