#include <iostream>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  if( N > M ) swap(N,M);
  if( N + 1 < M ){
    cout << 0 << endl;
    return 0;
  }
  unsigned long long c = 1;

  for( unsigned long long i = 1 ; i <= N ; ++i ){

    c = ( c * i*i  ) % 1000000007;
  }
  if( N < M ) c = c * M % 1000000007;
  else c = c * 2 % 1000000007; 
  cout << c << endl;
}