#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000005;
using lint = long long;
const int mod = 1e9 + 7;

int n, m;

int main(){
	cin >> n >> m;
	if(n > m) swap(n, m);
	lint ret = 0;
	if(n + 1 == m) ret = 1;
	if(n == m) ret = 2;
	for(int i=1; i<=n; i++) ret = ret * i % mod;
	for(int i=1; i<=m; i++) ret = ret * i % mod;
	cout << ret << endl;
}
