#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
int TDiam(BiDGraph& graph) {
	function<pii(int, int, int)> dfs = [&](int cur, int dis, int from) {
		pii Max = { dis,cur };
		REP(i, (int)graph.g[cur].size()) {
			if (graph.g[cur][i].first != from) {
				Max = max(Max, dfs(graph.g[cur][i].first, dis + graph.g[cur][i].second, cur));
			}
		}

		return Max;
	};

	pii S = dfs(0, 0, -1);
	pii G = dfs(S.second, 0, -1);

	return G.first;
}

template<typename T>
class Lazy_Segment_Tree {//0-indexed 半開
public:
	vector<T> data, lazy;
	int n;
	Lazy_Segment_Tree(int a) :n(1) {
		while (n < a) n *= 2;
		data.resize(n * 2 - 1);
		lazy.resize(n * 2 - 1);
	}

	void add(int a, int b, T ad, int num = 0, int base = 1) {
		int l = (num + 1 - base) * (n / base), r = l + n / base;
		if (a == l && b == r)
			lazy[num] += ad;
		else {
			data[num] += ad*(b - a);
			int nr = (l + r) / 2;
			if (nr > a) add(a, min(b, nr), ad, num * 2 + 1, base * 2);
			if (nr < b) add(max(a, nr), b, ad, num * 2 + 2, base * 2);
		}
	}

	T sum(int a, int b, int num = 0, int base = 1) {
		int l = (num + 1 - base) * (n / base), r = l + n / base;
		data[num] += lazy[num] * (r - l);
		if (num < n - 1) lazy[num * 2 + 1] += lazy[num], lazy[num * 2 + 2] += lazy[num];
		lazy[num] = T();
		if (a == l && b == r)
			return data[num];
		else {
			int nr = (l + r) / 2;
			T ret = T();
			if (nr > a) ret += sum(a, min(b, nr), num * 2 + 1, base * 2);
			if (nr < b) ret += sum(max(a, nr), b, num * 2 + 2, base * 2);
			return ret;
		}
	}
};
class Heavy_Light_Decomposition {
public:
	BiDGraph g, compg;
	vector<int> sz, depth, chain, par;

	int bn = 0;
	vector<int> bvn, inbn;
	vector<vector<int>> bv;

	Heavy_Light_Decomposition(BiDGraph graph, int root) :
		g(graph), compg(graph.vn), sz(graph.vn, 1), depth(graph.vn), chain(graph.vn), par(graph.vn),
		bvn(graph.vn), inbn(graph.vn) {
		getsz(root, root);
		bv.push_back(vector<int>());
		HLD(root, -1, root, 0);
	}

	int getsz(int cur, int p) {
		par[cur] = p;
		for (auto itr : g.g[cur])
			if (p != itr.first)
				depth[itr.first] = depth[cur] + 1, sz[cur] += getsz(itr.first, cur);
		return sz[cur];
	}

	void HLD(int cur, int p, int head, int num) {
		chain[cur] = head, bvn[cur] = num;
		inbn[cur] = bv[num].size(), bv[num].push_back(cur);
		pii Maxc = { -1,-1 };
		for (auto itr : g.g[cur])
			if (itr.first != p)
				Maxc = max(Maxc, { sz[itr.first], itr.first });


		for (auto itr : g.g[cur])
			if (itr.first != p) {
				int nb = num;
				if (itr.first != Maxc.second) {
					bv.push_back(vector<int>());
					nb = ++bn;
				}
				HLD(itr.first, cur, itr.first == Maxc.second ? head : itr.first, nb);
			}
	}


	int lca(int a, int b) {
		if (chain[a] == chain[b]) return depth[a] < depth[b] ? a : b;
		if (depth[chain[a]] > depth[chain[b]])
			return lca(par[chain[a]], b);
		return lca(a, par[chain[b]]);
	}

	void for_each_edge(int a, int b, function<void(int, int)> func) {
		if (chain[a] == chain[b]) return func(inbn[a] < inbn[b] ? a : b, inbn[a] < inbn[b] ? b : a);
		if (depth[chain[a]] < depth[chain[b]]) swap(a, b);
		for_each_edge(a, chain[a], func), for_each_edge(par[chain[a]], b, func);
	}
};

signed main() {
	int n, m;
	scanf("%d %d", &n, &m);

	if (abs(n - m) > 1)
		printf("0\n");
	else {
		ll ans = n == m ? 2 : 1;
		rep(i, 1, n+1) {
			ans *= i;
			ans %= MODU;
		}
		rep(i, 1, m+1) {
			ans *= i;
			ans %= MODU;
		}
		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 256