import sys

readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)

INF = float('inf')

MOD = 10 ** 9 + 7



def main():

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

    mod = 10 ** 9 + 7



    table = [1]

    tmp = 1

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

        tmp *= i

        tmp %= mod

        table.append(tmp)



    if abs(N - M) > 1:

        print((0))

    elif abs(N - M) == 1:

        print((table[N] * table[M] % mod))

    else:

        print((2 * table[N] * table[M] % mod))







if __name__ == '__main__':

    main()

import sys

readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)

INF = float('inf')

MOD = 10 ** 9 + 7



def main():

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

    if abs(N-M)>1:

        print('0')

    elif N==M:

        fact=[1]*(N+1)

        for i in range(N):

            fact[i+1] = fact[i]*(i+1)%MOD

        ans = 2*fact[N]*fact[M]%MOD

        print(ans)

    else:

        fact = [1] * (N + 3)

        for i in range(N+2):

            fact[i + 1] = fact[i] * (i + 1)%MOD

        ans = fact[N] * fact[M]%MOD

        print(ans)

if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7


def main():
    N, M = list(map(int, input().split()))
    mod = 10**9 + 7
    table = [1]
    tmp = 1
    for i in range(1, N + M + 1):
        tmp *= i
        tmp %= mod
        table.append(tmp)
    if abs(N - M) > 1:
        print((0))
    elif abs(N - M) == 1:
        print((table[N] * table[M] % mod))
    else:
        print((2 * table[N] * table[M] % mod))


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7


def main():
    N, M = list(map(int, readline().split()))
    if abs(N - M) > 1:
        print("0")
    elif N == M:
        fact = [1] * (N + 1)
        for i in range(N):
            fact[i + 1] = fact[i] * (i + 1) % MOD
        ans = 2 * fact[N] * fact[M] % MOD
        print(ans)
    else:
        fact = [1] * (N + 3)
        for i in range(N + 2):
            fact[i + 1] = fact[i] * (i + 1) % MOD
        ans = fact[N] * fact[M] % MOD
        print(ans)


if __name__ == "__main__":
    main()

-    N, M = list(map(int, input().split())) -    mod = 10**9 + 7 -    table = [1] -    tmp = 1 -    for i in range(1, N + M + 1): -        tmp *= i -        tmp %= mod -        table.append(tmp) +    N, M = list(map(int, readline().split())) -        print((0)) -    elif abs(N - M) == 1: -        print((table[N] * table[M] % mod)) +        print("0") +    elif N == M: +        fact = [1] * (N + 1) +        for i in range(N): +            fact[i + 1] = fact[i] * (i + 1) % MOD +        ans = 2 * fact[N] * fact[M] % MOD +        print(ans) -        print((2 * table[N] * table[M] % mod)) +        fact = [1] * (N + 3) +        for i in range(N + 2): +            fact[i + 1] = fact[i] * (i + 1) % MOD +        ans = fact[N] * fact[M] % MOD +        print(ans)