#include "bits/stdc++.h"
using namespace std;
const int mod = 1e9 + 7;
int n , m;
int fact(int n){
	if(n <= 1){
		return 1;
	}
	return (1LL * n * fact(n - 1)) % mod;
}
int main(){
	cin >> n >> m;
	if(n == m){
		cout << (2LL * fact(n) * fact(m)) % mod;
	}
	else if(n == m + 1 || m == n + 1){
		cout << (1LL * fact(n) * fact(m)) % mod;
	}
	else{
		cout << 0;
	}
	cout << endl;
}