#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e5+3;
const int p=1e9+7;
int n,m;
ll f[N];
void init(){
	f[0]=1;
	for(int i=1;i<N;i++) f[i]=f[i-1]*i%p;
}
int main(){
	init();
    cin>>n>>m;
    if(abs(n-m)>1){
    	cout<<0<<endl;
    	return 0;
    }
    if(n==m){
    	cout<<2*f[n]*f[m]%p<<endl;
    }
    else cout<<f[n]*f[m]%p<<endl;
    return 0;
}