// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long mod = 10L^^9 + 7L;
long n, m;

void main() {
    scan(n, m);

    if (n < m) swap(n, m);

    if (n == m) {
        long ans = 1;

        foreach (i ; 1 .. n + 1) {
            ans *= (1L * i * i) % mod;
            ans %= mod;
        }

        (ans *= 2) %= mod;

        writeln(ans);
    }
    else if (n == m + 1) {
        long ans = 1;

        foreach (i ; 1 .. n) {
            ans *= (1L * i * i) % mod;
            ans %= mod;
        }

        (ans *= n) %= mod;

        writeln(ans);
    }
    else {
        writeln(0);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}
