void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    long mod = 10 ^^ 9 + 7;

    long factorial(long x)
    {
        long result = 1;

        foreach (i; 2 .. x+1)
        {
            result = result * i % mod;
        }

        return result;
    }

    long cnt;
    if (n == m)
    {
        cnt = factorial(n) * factorial(m) % mod;
        cnt = cnt * 2 % mod;
    }
    else if (abs(n - m) == 1)
    {
        cnt = factorial(n) * factorial(m) % mod;
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;