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

mod=10**9+7

import sys

sys.setrecursionlimit(100002)

def kaijou(x):

  if x==1:

    return 1

  else:

    return ((x%mod)*kaijou(x-1))%mod



if abs(m-n)==1:

  n2=kaijou(n)

  m2=kaijou(m)

  print(((n2*m2)%mod))

elif abs(m-n)==0:

  n2=kaijou(n)

  m2=kaijou(m)

  print((2*(n2*m2)%mod))

else:

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

mod=10**9+7

nkai=1

mkai=1

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

  nkai*=(i%mod)

  nkai=(nkai%mod)

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

  mkai*=(i%mod)

  mkai=(mkai%mod)

if abs(n-m)>=2:

  print((0))

elif abs(n-m)==1:

  print(((mkai*nkai)%mod))

elif abs(n-m)==0:

  print(((mkai*nkai*2)%mod))
n, m = list(map(int, input().split()))
mod = 10**9 + 7
import sys

sys.setrecursionlimit(100002)


def kaijou(x):
    if x == 1:
        return 1
    else:
        return ((x % mod) * kaijou(x - 1)) % mod


if abs(m - n) == 1:
    n2 = kaijou(n)
    m2 = kaijou(m)
    print(((n2 * m2) % mod))
elif abs(m - n) == 0:
    n2 = kaijou(n)
    m2 = kaijou(m)
    print((2 * (n2 * m2) % mod))
else:
    print((0))

n, m = list(map(int, input().split()))
mod = 10**9 + 7
nkai = 1
mkai = 1
for i in range(1, n + 1):
    nkai *= i % mod
    nkai = nkai % mod
for i in range(1, m + 1):
    mkai *= i % mod
    mkai = mkai % mod
if abs(n - m) >= 2:
    print((0))
elif abs(n - m) == 1:
    print(((mkai * nkai) % mod))
elif abs(n - m) == 0:
    print(((mkai * nkai * 2) % mod))

-import sys - -sys.setrecursionlimit(100002) - - -def kaijou(x): -    if x == 1: -        return 1 -    else: -        return ((x % mod) * kaijou(x - 1)) % mod - - -if abs(m - n) == 1: -    n2 = kaijou(n) -    m2 = kaijou(m) -    print(((n2 * m2) % mod)) -elif abs(m - n) == 0: -    n2 = kaijou(n) -    m2 = kaijou(m) -    print((2 * (n2 * m2) % mod)) -else: +nkai = 1 +mkai = 1 +for i in range(1, n + 1): +    nkai *= i % mod +    nkai = nkai % mod +for i in range(1, m + 1): +    mkai *= i % mod +    mkai = mkai % mod +if abs(n - m) >= 2: +elif abs(n - m) == 1: +    print(((mkai * nkai) % mod)) +elif abs(n - m) == 0: +    print(((mkai * nkai * 2) % mod))