#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
template <int mod>
struct ModInt
{
    ll x;

    constexpr ModInt(ll a = 0) noexcept
    {
        x = a % mod;
    }
    constexpr ll value() noexcept
    {
        return x;
    }
    constexpr const ll value() const noexcept
    {
        return x;
    }
    constexpr ModInt Pow(ll n) noexcept
    {
        ModInt<mod> ans(1), mul(x);
        for (int i = 0; i < 31; i++)
        {
            if (n & (1 << i))
            {
                ans *= mul;
            }
            mul *= mul;
        }
        return ans;
    }
    constexpr ModInt &operator+=(const ModInt y) noexcept
    {
        x += y.x;
        if (x >= mod)
        {
            x -= mod;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt y) noexcept
    {
        if (x < y.x)
        {
            x += mod;
        }
        x -= y.x;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt y) noexcept
    {
        x = x * y.x % mod;
        return *this;
    }
    constexpr ModInt factorial() noexcept
    {
        int k = x;
        ModInt<mod> tmp(x);
        for (int i = 1; i < k; i++)
        {
            tmp *= ModInt<mod>(k - i);
        }
        return tmp;
    }
    constexpr ll inverse() noexcept
    {
        return this->Pow(mod - 2).x;
    }
    constexpr ModInt &operator/=(const ModInt y) noexcept
    {
        return (*this) * y.Pow(mod - 2);
    }
    constexpr ModInt operator+(const ModInt y) const noexcept
    {
        return ModInt(*this) += y;
    }
    constexpr ModInt operator*(const ModInt y) const noexcept
    {
        return ModInt(*this) *= y;
    }
    constexpr ModInt operator-(const ModInt y) const noexcept
    {
        return ModInt(*this) -= y;
    }
    constexpr ModInt operator/(const ModInt y) const noexcept
    {
        return *this /= y;
    }
};
int main()
{
    int N, M;
    cin >> N >> M;
    ModInt<(int)1e9 + 7> T(N), S(M);
    if (abs(N - M) > 1)
    {
        cout << 0;
        return 0;
    }
    if (N == M)
    {

        cout << ((T.factorial() * S.factorial()) * ModInt<(int)1e9 + 7>(2)).value();
    }
    else
    {
        cout << (T.factorial() * S.factorial()).value();
    }

    return 0;
}


Measured memory_bytes: 256