#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll p[100009], mod=1000000007;
ll n, m ;
int main()
{
	IO;
	p[0]=1;
	for (int i=1; i<=100000; i++)
		p[i]=(i*p[i-1])%mod;
	cin>>n>>m;
	if (abs(n-m)>1)
		return cout<<0, 0;
	if (abs(n-m)==1)
		cout<<(p[n]*p[m])%mod;
	else
		cout<<((2*p[n]*p[m])%mod);
}
