import sys
sys.setrecursionlimit(100000)

d = 10**9 + 7


def factorial(n):
    if (n > 1):
        return (n % d) * factorial(n-1)
    return 1


n, m = map(int, input().split())
ans = (factorial(n) % d) * (factorial(m) % d)
ans %= d
if n == m:
    ans *= 2

print(ans)
