#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#include <bits/stdc++.h>

namespace NyaGadgetModLL
{	// MOD ライブラリ
	using namespace std;

	template<long long mod> struct ModLL
	{
		long long x;

		// コンストラクタ
		ModLL()
		{
			x = 0;
		}
		ModLL(long long x_)
		{
			x = x_ % mod + mod;
			if (x >= mod)
				x -= mod;
		}

		// 符号
		ModLL operator + () const { return x; }
		ModLL operator - () const { return (-x < 0) ? mod - x : -x; }

		// 加減乗除演算子
		ModLL& operator += (ModLL r)
		{
			if ((x += r.x) >= mod)
				x -= mod;
			return *this;
		}
		ModLL & operator -= (ModLL r)
		{
			if ((x -= r.x) < 0)
				x += mod;
			return *this;
		}
		ModLL& operator *= (ModLL r)
		{
			x = (unsigned long long) x * r.x % mod;
			return *this;
		}
		ModLL& operator /= (ModLL r)
		{
			x = x * Inv(r.x, mod) % mod;
			return *this;
		}

		ModLL operator + (ModLL r) const { return ModLL(*this) += r; }
		ModLL operator - (ModLL r) const { return ModLL(*this) -= r; }
		ModLL operator * (ModLL r) const { return ModLL(*this) *= r; }
		ModLL operator / (ModLL r) const { return ModLL(*this) /= r; }

		// 逆元 x^{-1} (主に除算演算子で使用)
		long long Inv(long long a, long long m)
		{
			long long b = m, u = 1, v = 0;

			while (b)
			{
				long long t = a / b;
				a -= t * b; swap(a, b);
				u -= t * v; swap(u, v);
			}

			u %= m;

			return (u < 0) ? u + m : u;
		}

		// 比較演算子
		bool operator == (ModLL & r) const { return x == r.x; }
		bool operator != (ModLL & r) const { return x != r.x; }
		bool operator <  (ModLL & r) const { return x < r.x; }
		bool operator <= (ModLL & r) const { return x <= r.x; }
		bool operator >  (ModLL & r) const { return x > r.x; }
		bool operator >= (ModLL & r) const { return x >= r.x; }

		// 入出力演算子
		friend ostream& operator << (ostream & s, ModLL<mod> a)
		{
			s << a.x;
			return s;
		}
		friend istream& operator >> (istream & s, ModLL<mod> & a)
		{
			s >> a.x;
			return s;
		}
	};

	//*******************************************
	// [sample code]
	//
	//using namespace NyaGadgetModLL;
	//using mll = ModLL<1000000007>;
	//
	//int main(void)
	//{
	//	mll x, y(1000000009);
	//  mll div_x(12345678900000);
	//  mll div_y(100000);
	//
	//	div_x /= div_y;
	//
	//	cout << "x = " << x << endl;
	//  cout << "y = " << y << endl;
	//  cout << "div_x = " << div_x << endl;
	//	return 0;
	//}
	//*******************************************
	// [output]
	//
	// x = 0
	// y = 2
	// div_x = 123456789
	//*******************************************
}


#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

using namespace NyaGadgetModLL;
using mll = ModLL<1000000007>;

int main(void)
{
	mll n, m; cin >> n >> m;

	mll sub = 1;
	if (n < m && m - n != sub)
	{
		cout << 0;
		return 0;
	}
	else if (m < n && n - m != sub)
	{
		cout << 0;
		return 0;
	}
	
	mll ans = 1;
	mll max = 1;
	if (m != n)
	{
		ans = m;
		max = m;

		for (mll i = 1; i < max; i += 1)
		{
			m -= 1;
			ans *= m;
		}

		ans *= n;
		max = n;

		for (mll i = 1; i < max; i += 1)
		{
			n -= 1;
			ans *= n;
		}
	}
	else
	{
		ans = m;
		max = m;
		for (mll i = 1; i < max; i += 1)
		{
			m -= 1;
			ans *= m;
		}
		ans *= n;
		for (mll i = 1; i < max; i += 1)
		{
			n -= 1;
			ans *= n;
		}
		ans *= 2;
	}

	cout << ans;
	return 0;
}




Measured memory_bytes: 256