import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

const ulong MOD = 1_000_000_007;

void main(){
	long n = read.to!long;
	long m = read.to!long;
	
	ulong ans;
	
	if(n < m - 1 || n > m + 1) ans = 0;
	else if(n == m) ans = 2 * f(n) * f(n) % MOD;
	else ans = f(m) * f(n) % MOD;
	
	ans.writeln;
		
	}

ulong f(long n){
	ulong res = 1;
	for(long i = 1; i <= n; i ++){
		res *= i;
		res %= MOD;
		}
	return res;
	}