#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long fm(int n)
{
  long a = 1;
  while(n) a = (a * (long)n--) % MOD;
  return a;
}
int main(void)
{
  int n, m;
  long ans;
  cin >> n >> m;
  if(abs(n - m) > 1) ans = 0;
  else if(n == m) ans = (2 * fm(n) * fm(n)) % MOD;
  else ans = (fm(n) * fm(m)) % MOD;
  cout << ans << endl;
  return 0;
}