from math import factorial as F

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

N, M = min(N, M), max(N, M)

mod = 10**9+7



if M-N > 1:

    print((0))

elif M-N == 1:

    print((F(M)*F(N) % mod))

else:

    print((F(M)**2*2 % mod))

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

N, M = min(N, M), max(N, M)

mod = 10**9+7



g = [1, 1]

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

    g.append((g[-1] * i) % mod)



if M-N > 1:

    print((0))

elif M-N == 1:

    print((g[M]*g[N] % mod))

else:

    print((g[M]**2*2 % mod))

from math import factorial as F

N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9 + 7
if M - N > 1:
    print((0))
elif M - N == 1:
    print((F(M) * F(N) % mod))
else:
    print((F(M) ** 2 * 2 % mod))

N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9 + 7
g = [1, 1]
for i in range(2, M + 1):
    g.append((g[-1] * i) % mod)
if M - N > 1:
    print((0))
elif M - N == 1:
    print((g[M] * g[N] % mod))
else:
    print((g[M] ** 2 * 2 % mod))

-from math import factorial as F - +g = [1, 1] +for i in range(2, M + 1): +    g.append((g[-1] * i) % mod) -    print((F(M) * F(N) % mod)) +    print((g[M] * g[N] % mod)) -    print((F(M) ** 2 * 2 % mod)) +    print((g[M] ** 2 * 2 % mod))