# include <cstdio>
# include <iostream>
# define R register int

using namespace std;

const int mod=1e9+7;
int n,m;

int fac (int x)
{
	int s=1;
	for (R i=1;i<=x;++i) s=1LL*s*i%mod;
	return s;
}

int main()
{
	scanf("%d%d",&n,&m);
	if(n<m) swap(n,m);
	if(n==m)
		printf("%lld\n",2LL*fac(n)*fac(m)%mod);
	else if(n==m+1)
		printf("%lld\n",1LL*fac(n)*fac(m)%mod);
	else puts("0");
	return 0;	
} 