#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll fact[100001];
int main(){
  fact[0]=1LL;
  for(ll i=1;i<=100000;++i)
    fact[i]=(fact[i-1]*i)%mod;
  int n,m;
  cin >> n >> m;
  if(m>n) swap(n,m);
  if(n==m){
    cout << (2*fact[n]*fact[n])%mod << endl;
  }
  else if(n==m+1)
    cout << (fact[n]*fact[m])%mod << endl;
  else
    cout << 0 << endl;
  return 0;
}
