#include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
#define MOD 1000000007
using namespace std;

LL n,m,ans;

LL cal(LL x){
	LL i;LL re=1;
	for(i=1;i<=x;i++){
		re=(re*i)%MOD;
	}
	return re;
}

int main(){
	scanf("%lld%lld",&n,&m);
	if(abs(m-n)>=2){
		printf("0\n");
		return 0;
	}
	if(m==n){
		LL t=cal(n);
		ans=(t*t*2)%MOD;
	}
	else{
		ans=(cal(m)*cal(n))%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}
