N,M = list(map(int,input().split()))

if N > M: N,M = M,N

if M-N > 1:

    print((0))

    exit()



MOD = 10**9+7



fac = [1]

for n in range (1,M+2):

    f = (fac[n-1]*n) % MOD

    fac.append(f)



if M-N == 1:

    ans = (fac[M] * fac[N]) % MOD

else:

    ans = (fac[M] * fac[N] * 2) % MOD

print(ans)
N,M = list(map(int,input().split()))

if N > M:

    N,M = M,N

if M-N > 1:

    print((0))

    exit()



MOD = 10**9+7



fac = [1]

for n in range(1, M + 2):

    fac.append((fac[-1] * n) % MOD)



if M == N:

    print(((fac[M] * fac[N] * 2) % MOD))

else:

    print(((fac[M] * fac[N]) % MOD))
N, M = list(map(int, input().split()))
if N > M:
    N, M = M, N
if M - N > 1:
    print((0))
    exit()
MOD = 10**9 + 7
fac = [1]
for n in range(1, M + 2):
    f = (fac[n - 1] * n) % MOD
    fac.append(f)
if M - N == 1:
    ans = (fac[M] * fac[N]) % MOD
else:
    ans = (fac[M] * fac[N] * 2) % MOD
print(ans)

N, M = list(map(int, input().split()))
if N > M:
    N, M = M, N
if M - N > 1:
    print((0))
    exit()
MOD = 10**9 + 7
fac = [1]
for n in range(1, M + 2):
    fac.append((fac[-1] * n) % MOD)
if M == N:
    print(((fac[M] * fac[N] * 2) % MOD))
else:
    print(((fac[M] * fac[N]) % MOD))

-    f = (fac[n - 1] * n) % MOD -    fac.append(f) -if M - N == 1: -    ans = (fac[M] * fac[N]) % MOD +    fac.append((fac[-1] * n) % MOD) +if M == N: +    print(((fac[M] * fac[N] * 2) % MOD)) -    ans = (fac[M] * fac[N] * 2) % MOD -print(ans) +    print(((fac[M] * fac[N]) % MOD))