from math import factorial

large_p = 10**9 + 7



def main():

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

    if (abs(n-m)) >= 2:

        print((0))

    else:

        np = factorial(n)

        mp = factorial(m)



        if abs(n-m) == 1:

            r = (np * mp) % large_p

            print(r)

        else:

            r = ((np * mp) * 2) % large_p

            print(r)



if __name__ == '__main__':

    main()

large_p = 10**9 + 7



def main():

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

    if (abs(n-m)) >= 2:

        print((0))

    else:

        

        np = 1

        for i in range(n,0,-1):

            np = (np * i) % large_p

        mp = 1

        for i in range(m,0,-1):

            mp = (mp * i) % large_p



        if abs(n-m) == 1:

            r = (np * mp) % large_p

            print(r)

        else:

            r = ((np * mp) * 2) % large_p

            print(r)



if __name__ == '__main__':

    main()

from math import factorial

large_p = 10**9 + 7


def main():
    n, m = list(map(int, input().split()))
    if (abs(n - m)) >= 2:
        print((0))
    else:
        np = factorial(n)
        mp = factorial(m)
        if abs(n - m) == 1:
            r = (np * mp) % large_p
            print(r)
        else:
            r = ((np * mp) * 2) % large_p
            print(r)


if __name__ == "__main__":
    main()

large_p = 10**9 + 7


def main():
    n, m = list(map(int, input().split()))
    if (abs(n - m)) >= 2:
        print((0))
    else:
        np = 1
        for i in range(n, 0, -1):
            np = (np * i) % large_p
        mp = 1
        for i in range(m, 0, -1):
            mp = (mp * i) % large_p
        if abs(n - m) == 1:
            r = (np * mp) % large_p
            print(r)
        else:
            r = ((np * mp) * 2) % large_p
            print(r)


if __name__ == "__main__":
    main()

-from math import factorial - -        np = factorial(n) -        mp = factorial(m) +        np = 1 +        for i in range(n, 0, -1): +            np = (np * i) % large_p +        mp = 1 +        for i in range(m, 0, -1): +            mp = (mp * i) % large_p