#include <iostream>  
#include <algorithm>  
#include <functional>  
#include <vector>  
#include <map>
#include <string>
#include <queue>
#include <deque> 
#include <cmath>
#include <math.h>
using namespace std;
	double pi=acos(-1);
	#define mod 1000000007
	long long int modexp(long long int a, int b){ 
	long long int t=1;
	while( b != 0){
		if( b%2 == 1)
			t = (t*a)%mod ;
		a = (a*a)%mod;
		b /= 2;
	}
	return t%mod;
}
int main(){
	//freopen("input.txt", "r", stdin);   
 	//freopen("output.txt", "w", stdout);
 	int n=1,m=1;
 	scanf("%d %d",&n,&m);
 	if(n>m){
 		int te=m;
 		m=n;
 		n=te;
 	}
 	long long int ans=1;
 	int i;
 	for(i=1;i<=n;i++) ans=(ans*i)%mod;
 	if(m-n>=2) printf("0\n");
 	else if(m-n==1) printf("%lld\n",(ans*(ans*m)%mod)%mod );
 	else if(m==n) printf("%lld\n", (2*ans*ans)%mod );
	return 0;
}