process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

var mod = 10**9+7;

function fact(n) {
  /*
  function iter(x, temp){
   if(x==0) {
      return temp%mod;
   }
   return iter(x-1, (temp*x)%mod);
  }
  return iter(n, 1);
  */
  var ans = 1;
  for(var i = 2; i <= n; i++){
    ans = (ans*i)%mod;
  }
  return ans;
}
function main(inputs) {
  var a = inputs[0].split(" ").map(function(a){return parseInt(a);});
  var A = a[0];
  var B = a[1];
  var max = Math.max(A, B);
  var min = Math.min(A, B);
  var ans;
  var temp;
  if(max - min ==1){
    temp = fact(min);
    ans = (max * temp)%mod;
    ans = (ans * temp)%mod;
  }else if(max == min){
    temp = fact(min);
    ans = (2 * temp)%mod;
    ans = (ans * temp)%mod;
  }else{
    ans = 0;
  }
  console.log(ans);
}
