#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
const LL MOD = 1000000007;
LL n, m;
 
LL fac(LL x){
	LL res = 1;
	while (x)
		res = (res * (x--)) % MOD;
	return res;
}
 
int main(){
	scanf("%lld%lld", &n, &m);
	if (n > m) swap(n, m);
	if (n <= m-2) puts("0");
	else if (n == m-1) printf("%lld\n", fac(n)*fac(m)%MOD);
	else printf("%lld\n", 2*fac(n)*fac(m)%MOD);
	return 0;
}