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



# AtCoder Beginner Contest

# Problem C



if __name__ == '__main__':

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

    diff = abs(n - m)

    n_factorial = 1

    m_factorial = 1

    large_number = 10 ** 9 + 7



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

        n_factorial = (n_factorial * i) % large_number



    for k in range(1, m + 1):

        m_factorial = (m_factorial * k) % large_number



    rate = 0



    if diff == 1:

        rate = 1

    elif diff == 0:

        rate = 2



    print(((n_factorial * m_factorial * rate) % large_number))

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



# AtCoder Beginner Contest

# Problem C

large_number = 10 ** 9 + 7





def factorial(number: int) -> int:

    value = 1



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

        value = (value * i) % large_number

    return value





if __name__ == '__main__':

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

    diff = abs(n - m)

    result = factorial(min(n, m))



    # See:

    # https://beta.atcoder.jp/contests/abc065/submissions/1654425

    if diff == 1:

        rate = 1

        print(((result * result * max(n, m) * rate) % large_number))

    elif diff == 0:

        rate = 2

        print(((result * result * rate) % large_number))

    else:

        print((0))

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    diff = abs(n - m)
    n_factorial = 1
    m_factorial = 1
    large_number = 10**9 + 7
    for i in range(1, n + 1):
        n_factorial = (n_factorial * i) % large_number
    for k in range(1, m + 1):
        m_factorial = (m_factorial * k) % large_number
    rate = 0
    if diff == 1:
        rate = 1
    elif diff == 0:
        rate = 2
    print(((n_factorial * m_factorial * rate) % large_number))

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
large_number = 10**9 + 7


def factorial(number: int) -> int:
    value = 1
    for i in range(1, number + 1):
        value = (value * i) % large_number
    return value


if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    diff = abs(n - m)
    result = factorial(min(n, m))
    # See:
    # https://beta.atcoder.jp/contests/abc065/submissions/1654425
    if diff == 1:
        rate = 1
        print(((result * result * max(n, m) * rate) % large_number))
    elif diff == 0:
        rate = 2
        print(((result * result * rate) % large_number))
    else:
        print((0))

+large_number = 10**9 + 7 + + +def factorial(number: int) -> int: +    value = 1 +    for i in range(1, number + 1): +        value = (value * i) % large_number +    return value + + -    n_factorial = 1 -    m_factorial = 1 -    large_number = 10**9 + 7 -    for i in range(1, n + 1): -        n_factorial = (n_factorial * i) % large_number -    for k in range(1, m + 1): -        m_factorial = (m_factorial * k) % large_number -    rate = 0 +    result = factorial(min(n, m)) +    # See: +    # https://beta.atcoder.jp/contests/abc065/submissions/1654425 +        print(((result * result * max(n, m) * rate) % large_number)) -    print(((n_factorial * m_factorial * rate) % large_number)) +        print(((result * result * rate) % large_number)) +    else: +        print((0))