# -*- coding: utf-8 -*-



from math import factorial



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





def solve(m, n):

    if m > n:

        m, n = n, m

    if n - m > 1:

        return 0

    fct = factorial(m)

    if n - m == 1:

        return fct ** 2 * n

    else:  # n - m == 0

        return fct ** 2 * 2





mod = 10 ** 9 + 7

ans = solve(m, n) % mod

print(ans)

# -*- coding: utf-8 -*-



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



mod = 10 ** 9 + 7





def factorial(x):

    ret = 1

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

        ret *= i

        ret %= mod



    return ret





def solve(m, n):

    if m > n:

        m, n = n, m

    if n - m > 1:

        return 0

    fct = factorial(m)

    if n - m == 1:

        return fct ** 2 * n % mod

    else:  # n - m == 0

        return fct ** 2 * 2 % mod





ans = solve(m, n)

print(ans)

# -*- coding: utf-8 -*-
from math import factorial

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


def solve(m, n):
    if m > n:
        m, n = n, m
    if n - m > 1:
        return 0
    fct = factorial(m)
    if n - m == 1:
        return fct**2 * n
    else:  # n - m == 0
        return fct**2 * 2


mod = 10**9 + 7
ans = solve(m, n) % mod
print(ans)

# -*- coding: utf-8 -*-
n, m = list(map(int, input().split()))
mod = 10**9 + 7


def factorial(x):
    ret = 1
    for i in range(1, x + 1):
        ret *= i
        ret %= mod
    return ret


def solve(m, n):
    if m > n:
        m, n = n, m
    if n - m > 1:
        return 0
    fct = factorial(m)
    if n - m == 1:
        return fct**2 * n % mod
    else:  # n - m == 0
        return fct**2 * 2 % mod


ans = solve(m, n)
print(ans)

-from math import factorial +n, m = list(map(int, input().split())) +mod = 10**9 + 7 -n, m = list(map(int, input().split())) + +def factorial(x): +    ret = 1 +    for i in range(1, x + 1): +        ret *= i +        ret %= mod +    return ret -        return fct**2 * n +        return fct**2 * n % mod -        return fct**2 * 2 +        return fct**2 * 2 % mod -mod = 10**9 + 7 -ans = solve(m, n) % mod +ans = solve(m, n)