import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto M = RD!long;

	if (abs(N - M) > 1)
	{
		writeln(0);
		return;
	}

	long cnt1 = 1, cnt2 = 1;
	foreach (i; 0..N)
	{
		modm(cnt1, N - i);
	}
	foreach (i; 0..M)
	{
		modm(cnt2, M - i);
	}
	long ans = cnt1;
	modm(ans, cnt2);
	if (N == M) modm(ans, 2);

	writeln(ans);
	stdout.flush();
}