#include <iostream>
#include <cmath>
using namespace std;
#define MOD 1000000007
long long kaijo(int a){
  long long kek = 1;
  for(int i = a; i > 0; i--){
    kek = (kek * i) % MOD;
  }
  return kek;
}
int main(){
  int n,m;cin>>n>>m;
  int kekka;
  if(abs(n-m) == 1){
    kekka = kaijo(m)*kaijo(n) % MOD;
  }else if(abs(n-m) == 0){
    kekka = kaijo(m)*kaijo(n) % MOD * 2 % MOD;
  }
  cout << kekka << endl;
}