// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <type_traits>

using namespace std;



using ll = int64_t;

#define int ll



#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)

#define REP(i, b) FOR(i, 0, b)

#define MP make_pair

#define PB push_back

#define EB emplace_back

#define ALL(x) x.begin(), x.end()



using pi = pair<int, int>;

using vi = vector<int>;

using ld = long double;



template <class T, class U>

ostream &operator<<(ostream &os, const pair<T, U> &p) {

  os << "(" << p.first << "," << p.second << ")";

  return os;

}



template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {

  os << "{";

  REP(i, (int)v.size()) {

    if (i)

      os << ",";

    os << v[i];

  }

  os << "}";

  return os;

}



ll read() {

  ll i;

  scanf("%" SCNd64, &i);

  return i;

}



void printSpace() { printf(" "); }



void printEoln() { printf("\n"); }



void print(ll x, int suc = 1) {

  printf("%" PRId64, x);

  if (suc == 1)

    printEoln();

  if (suc == 2)

    printSpace();

}



string readString() {

  static char buf[3341000];

  scanf("%s", buf);

  return string(buf);

}



char *readCharArray() {

  static char buf[3341000];

  static int bufUsed = 0;

  char *ret = buf + bufUsed;

  scanf("%s", ret);

  bufUsed += strlen(ret) + 1;

  return ret;

}



template <class T, class U> void chmax(T &a, U b) {

  if (a < b)

    a = b;

}



template <class T, class U> void chmin(T &a, U b) {

  if (b < a)

    a = b;

}



template <class T> T Sq(const T &t) { return t * t; }



const int mod = 1e9 + 7;

const int maxN = 1e5 + 5;

int fact[maxN];



signed main() {

  fact[1] = 1;

  for (int i = 2; i <= maxN; i++)

    fact[i] = (fact[i - 1] * i) % mod;

  int n, m;

  std::cin >> n >> m;

  if (abs(n - m) == 1)

    print((fact[n] * fact[m]) % mod);

  else if (n == m)

    print((fact[n] * fact[m] * 2) % mod);

  else

    print(0);

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#include <type_traits>

using namespace std;



using ll = long long;



#define rep(i, n) for (int i = 0; i < (n); ++i)

#define rrep(i, n) for (int i = 1; i <= (n); ++i)

#define drep(i, n) for (int i = (n)-1; i >= 0; --i)

#define ddrep(i, n) for (int i = n; i > 0; --i)

#define srep(i, s, t) for (int i = s; i < t; ++i)

#define ssrep(i, s, t) for (int i = s; i <= t; ++i)



#define rng(a) a.begin(), a.end()

#define rrng(a) a.rbegin(), a.rend()

#define pb push_back

#define eb emplace_back

#define fi first

#define se second



#define chmax(x, y) (x = max(x, y))

#define chmin(x, y) (x = min(x, y))



using pi = pair<int, int>;

using vi = vector<int>;

using vvi = vector<vi>;

using vl = vector<ll>;

using vvl = vector<vl>;

using ld = long double;



template <class T, class U>

ostream &operator<<(ostream &os, const pair<T, U> &p) {

    os << "(" << p.first << "," << p.second << ")";

    return os;

}



template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {

    os << "{";

    rep(i, (int)v.size()) {

        if (i)

            os << ",";

        os << v[i];

    }

    os << "}";

    return os;

}



template <typename T, size_t S> void printArray(const T (&array)[S]) {

    for (auto val : array)

        std::cout << val << ", ";

    std::cout << "\n";

}



const int mod = 1e9 + 7;

const int inf = 1e9 + 5;



struct mint {

    ll x;

    mint(ll x=0) : x(x%mod) {}

    mint& operator+=(const mint a) {

        if ((x += a.x) >= mod) x -= mod;

        return *this;

    }

    mint& operator-=(const mint a) {

        if ((x -= a.x) < 0) x += mod;

        return *this;

    }

    mint& operator*=(const mint a) {

        (x *= a.x) %= mod;

        return *this;

    }

    mint operator+(const mint a) {

        mint res(*this);

        return res+=a;

    }

    mint operator-(const mint a) {

        mint res(*this);

        return res-=a;

    }

    mint operator*(const mint a) {

        mint res(*this);

        return res*=a;

    }

};



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    cout << std::setprecision(10);



    int n, m; std::cin >> n >> m;

    if (abs(n-m) > 1) {

        std::cout << 0 << "\n";

        return 0;

    }

    mint ans = 1;

    rrep(i, n) ans *= i;

    rrep(i, m) ans *= i;

    if (n == m) {

        ans *= 2;

    }

    std::cout << ans.x << "\n";

}


// Fastest known solution for this problem: