#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int main(){
    int n = read(),m = read();
    if (abs(n-m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    LL ans1 = 1,ans2 = 1;
    for(int i=1; i<=n; i++){
        ans1 = ans1 * i % mod;
    }   
    for(int i=1; i<=m; i++){
        ans2 = ans2 * i % mod;
    }
    LL ans = (ans1 * ans2) % mod;
    if ((n & 1) == (m & 1))ans = ans * 2 % mod;
    cout << ans << endl;
    return 0;
}