#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

template <long long modulo> class Modulo {
private:
  long long inv() {
    long long p = mod - 2;
    long long ans = 1;
    for (; p != 0; p >>= 1LL) {
      if (p & 1LL)
        ans = (ans * x) % mod;
      x = (x * x) % mod;
    }
    return ans;
  }

public:
  long long mod = modulo;
  unsigned long long x;
  Modulo() : x(0) {}
  Modulo(signed int s) {
    while (s < 0)
      s += mod;
    x = s % mod;
  }
  Modulo(signed long long s) {
    while (s < 0)
      s += mod;
    x = s % mod;
  }
  operator int() { return (int)x; }
  operator long long() { return (long long)x; }
  Modulo &operator+=(Modulo q) {
    if ((x += q.x) >= mod)
      x -= mod;
    return *this;
  }
  Modulo &operator-=(Modulo q) {
    if ((x += mod - q.x) >= mod)
      x -= mod;
    return *this;
  }
  Modulo &operator*=(Modulo q) {
    x = (unsigned long long)x * q.x % mod;
    return *this;
  }
  Modulo &operator/=(Modulo q) {
    x = (unsigned long long)x * q.inv() % mod;
    return *this;
  }
  Modulo operator+(Modulo q) { return Modulo(*this) += q; }
  Modulo operator-(Modulo q) { return Modulo(*this) -= q; }
  Modulo operator*(Modulo q) { return Modulo(*this) *= q; }
  Modulo operator/(Modulo q) { return Modulo(*this) /= q; }
  template <typename T> Modulo &operator+=(const T q) {
    if ((x += q) >= mod)
      x -= mod;
    return *this;
  }
  template <typename T> Modulo &operator-=(const T q) {
    if ((x += mod - q) >= mod)
      x -= mod;
    return *this;
  }
  template <typename T> Modulo &operator*=(const T q) {
    x = (unsigned long long)x * q % mod;
    return *this;
  }
  template <typename T> Modulo &operator/=(const T q) {
    x = (unsigned long long)x * (Modulo(q)).inv() % mod;
    return *this;
  }
  template <typename T> Modulo operator+(const T q) {
    return Modulo(*this) += q;
  }
  template <typename T> Modulo operator-(const T q) {
    return Modulo(*this) -= q;
  }
  template <typename T> Modulo operator*(const T q) {
    return Modulo(*this) *= q;
  }
  template <typename T> Modulo operator/(const T q) {
    return Modulo(*this) /= q;
  }
};

const ll MOD = 1000000007LL;

void solve(long long N, long long M) {
  Modulo<1000000007> ans(1);

  if (abs(N - M) > 1) {
    ans = 0;
  } else if (N != M) {
    for (ll i = 1; i <= N; ++i)
      ans *= i;
    for (ll i = 1; i <= M; ++i)
      ans *= i;
  } else {
    for (ll i = 1; i <= N; ++i)
      ans *= i;
    for (ll i = 1; i <= M; ++i)
      ans *= i;
    ans *= 2;
  }

  cout << (ll)ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long M;
  long long N;
  cin >> N;
  cin >> M;
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256