#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n,m;
    cin >> n >> m;
    if(n < m)
        swap(n,m);
    if(n-1 > m){
        puts("0");
        return 0;
    }
    ll ans = 1;
    for(int i = 1; i <= n; ++i)
        ans = (ans * i)%MOD;
    for(int i = 1; i <= m; ++i)
        ans = (ans * i)%MOD;
    if(n == m)
        ans = (ans*2)%MOD;
    cout << ans << '\n';
}
