#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int mod=1e9+7,N=100005;
int fac[N],n,m,ans;
void read(int &x)
{
    x=0;
    int y=1;
    char c=getchar();
    while (c>'9'||c<'0')
    {
        if (c=='-')
            y=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    x*=y;
}
int main()
{
	read(n);
	read(m);
	if (n>m)
		swap(n,m);
	fac[0]=1;
	for (int i=1;i<=m;++i)
		fac[i]=(ll)fac[i-1]*i%mod;
	if (n==m)
		ans=(ll)fac[n]*fac[m]*2%mod;
	else
	{
		if (n+1==m)
			ans=(ll)fac[n]*fac[m]%mod;
		else
			ans=0;
	}
	cout<<ans;
	return 0;
}