// Copyright 2017 wu_qing
#include <cstdio>
#include <cstdint>
const int N = 1e5 + 10, mod = 1e9 + 7;
int x, y;
int64_t j[N], ans;
int main() {
    j[0] = 1;
    for (int i = 1; i < N; i++)
        j[i] = j[i - 1] * i % mod;
    scanf("%d%d", &x, &y);
    if (x - y > 1 || x - y < -1)
        ans = 0;
    else
        ans = j[x] * j[y] % mod;
    if (x == y)
        ans = ans * 2 % mod;
    printf("%lld\n", ans);
    return 0;
}
