N, M = list(map(int, input().split()))

# N, M = 100000, 100000

# N, M = 2, 3



mod = 10 ** 9 + 7

if abs(N - M) >= 2:

    print((0))

else:

    if N == M:

        prod = 1

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

            prod = (prod * i) % mod

        print(((prod * prod * 2) % mod))

    else:

        if N < M:

            N, M = M, N

        prod = 1

        ans = 1

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

            prod = (prod * i) % mod

            if i == M:

                ans = (ans * prod) % mod

        print(((ans * prod) % mod))



N, M = list(map(int, input().split()))

# N, M = 100000, 100000



mod = 10 ** 9 + 7

if N > M:

    N, M = M, N



if M - N >= 2:

    print((0))

elif M - N == 1:

    prod = 1

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

        prod = (prod * i) % mod

    print(((prod * prod * M) % mod))

else:

    prod = 1

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

        prod = (prod * i) % mod

    print(((2 * prod * prod) % mod))

N, M = list(map(int, input().split()))
# N, M = 100000, 100000
# N, M = 2, 3
mod = 10**9 + 7
if abs(N - M) >= 2:
    print((0))
else:
    if N == M:
        prod = 1
        for i in range(2, N + 1):
            prod = (prod * i) % mod
        print(((prod * prod * 2) % mod))
    else:
        if N < M:
            N, M = M, N
        prod = 1
        ans = 1
        for i in range(2, N + 1):
            prod = (prod * i) % mod
            if i == M:
                ans = (ans * prod) % mod
        print(((ans * prod) % mod))

N, M = list(map(int, input().split()))
# N, M = 100000, 100000
mod = 10**9 + 7
if N > M:
    N, M = M, N
if M - N >= 2:
    print((0))
elif M - N == 1:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print(((prod * prod * M) % mod))
else:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print(((2 * prod * prod) % mod))

-# N, M = 2, 3 -if abs(N - M) >= 2: +if N > M: +    N, M = M, N +if M - N >= 2: +elif M - N == 1: +    prod = 1 +    for i in range(1, N + 1): +        prod = (prod * i) % mod +    print(((prod * prod * M) % mod)) -    if N == M: -        prod = 1 -        for i in range(2, N + 1): -            prod = (prod * i) % mod -        print(((prod * prod * 2) % mod)) -    else: -        if N < M: -            N, M = M, N -        prod = 1 -        ans = 1 -        for i in range(2, N + 1): -            prod = (prod * i) % mod -            if i == M: -                ans = (ans * prod) % mod -        print(((ans * prod) % mod)) +    prod = 1 +    for i in range(1, N + 1): +        prod = (prod * i) % mod +    print(((2 * prod * prod) % mod))