import sys

readline = sys.stdin.readline

from math import factorial

MOD = 10 ** 9 + 7



def main():

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

    if abs(N-M) > 1:

        ans = 0

    elif N == M:

        ans = (factorial(N) % MOD) * (factorial(M) % MOD) * 2

    else:

        ans = (factorial(N) % MOD) * (factorial(M) % MOD)



    print((ans % MOD))





if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.readline

MOD = 10 ** 9 + 7



def factorial(N, mod=MOD):

    res = 1

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

        res *= i

        res %= mod

    return res



def main():

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

    if abs(N-M) > 1:

        ans = 0

    elif N == M:

        ans = factorial(N) * factorial(M) * 2

    else:

        ans = factorial(N) * factorial(M)



    print((ans % MOD))





if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.readline
from math import factorial

MOD = 10**9 + 7


def main():
    N, M = list(map(int, readline().rstrip().split()))
    if abs(N - M) > 1:
        ans = 0
    elif N == M:
        ans = (factorial(N) % MOD) * (factorial(M) % MOD) * 2
    else:
        ans = (factorial(N) % MOD) * (factorial(M) % MOD)
    print((ans % MOD))


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.readline
MOD = 10**9 + 7


def factorial(N, mod=MOD):
    res = 1
    for i in range(2, N + 1):
        res *= i
        res %= mod
    return res


def main():
    N, M = list(map(int, readline().rstrip().split()))
    if abs(N - M) > 1:
        ans = 0
    elif N == M:
        ans = factorial(N) * factorial(M) * 2
    else:
        ans = factorial(N) * factorial(M)
    print((ans % MOD))


if __name__ == "__main__":
    main()

-from math import factorial +MOD = 10**9 + 7 -MOD = 10**9 + 7 + +def factorial(N, mod=MOD): +    res = 1 +    for i in range(2, N + 1): +        res *= i +        res %= mod +    return res -        ans = (factorial(N) % MOD) * (factorial(M) % MOD) * 2 +        ans = factorial(N) * factorial(M) * 2 -        ans = (factorial(N) % MOD) * (factorial(M) % MOD) +        ans = factorial(N) * factorial(M)