/*
                           _________________
                      ____/:::::::::::::::::\_____
                   __/::::::::::::::::::::::::::::\___
                 _/:::::::::::::::::::::::::::::::::::\__
               _/::::::::::::::::::::::::::::::::::::::::\_
              /::::::::::::::::::::::::::::::::::::::::::::\
             |::::::::::::::::::::::::::::::::::::::::::::::\
            /::::::::::::::::::::::::::::::::::::::::::::::::\
           |:::/.:::::::;:::::::::::::::::::::::::::::::::::::|
          /:::/.:::::::/..:::::::::::::::::::::::::::::::::::::\
         |:::|.::::::;/.::::::::::::::::::::::::::::::::::::::::|
         |::/.::::::/..:::::::;;'.::::::::::::::::::::::::::::::|
         |:|.::::/./.::::::;;/..:::::::::::::::::::::::::::::::::|
         `:|.:::|.|.:::::;/..;;;;;;-'.:;;;-':::::::::::::::::::::|
          \|.:::|.|.:::;/.;;/  -..::'''...:::::::::::::::::::::::|
           \;;::|.|.::/.;/--__      |::::::::::::::::::::::::::::|
              \;;\\::/|/ =-__ --_  /::::::::::::::::::::::::::::::
                  \\/    /|  -.   |.::::::::::::::::::::::::::::::
                 _.'    /|'   /=  ||::::::::::::::::::::::::::::::
             _.-'      //'        ||::::::::::::::::::::::::::::::
            (          -          `|::::::::::::::::::::::::::::::
             \                      \:::::::::::::::::::::::::::::
              |  (c)Kolansburg      \::::::::::::::::::::::::::::
             /                      __/:::::::::::::::::::::::::::
             \                   __/::;::;;:::::::::::::::::::::::
             (`                 /;;;;/::|  \::::::::::::::::::::::
             |                 |'_,::::/ \ |::::::::::::::::::::::
            .'                _/::::::/  / /:::::::::::::::. .::::
            |                /.::;;:-'_)/_/::::::::::::::::...::::
 ----.__    |               |.::|   \___/::::::::::::::::::...::::
 :::::::`----\_____          \:::\.-'::::::::::::::::::::::...::::
 ;;;;;:::::::::::::`------     \:::::::::::::::::::::::::::...::::
      `-------:::::::\         /:::::::::::::::::::::::::::...::::
 ___.--------'::::::::\       |::::::::::::::::::::::::::::...::::
 :::::;;;:--:::::::::::|      /::::::::::::::::::::::::::::...::::
 ----'  _,-:.:::::::::::\    |.::::::::::::::::::::::::::::...::::
     __/.::::::::::::::::|   |.::::::::::::::::::::::::::::...::::
  __/.:::;;::::::::;/.:::|   |.::::::::::::::::::::::::::::. .::::
 /.::::;/ /.:::::;/ |.::::|   \_.:::::::::::::::::::::::::::::::::
 :::::/  /.:::::/  /.:::::|     \__.::::::::::::::::::::::::::::::
 ::::|  |.:::::/  /.:::::.|        \,::::::::::::::::::::::::::::
 ::::|  |.::::|   |.:::::/|       __/::::::::::::::::::::::::::::
 \.:::\  \.:::|   |.::::||| __.--::::::::::::::::::::::::::::::::
  \.:::\_ \.:::\   \.:::'/.::::::::::::::::::::::::::::::::::::::
   \.::::\ \.:::\   \.::::::::::::::::::::::::::::::::::::::::::
*/
 
#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <stack>
#include <random>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define X first
#define Y second

const long long N = 100100, M = 1000000007;
long long f[N], n, m;

int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("parray.in", "r", stdin);
	//freopen("parray.out", "w", stdout);
#endif
	//ios::sync_with_stdio(0);
	cin >> n >> m;
	if (abs(n - m) > 1)
	{
		cout << 0;
		return 0;
	}
	f[0] = 1;
	f[1] = 1;
	for (int i = 2; i <= max(n, m); i++)
	{
		f[i] = (f[i - 1] * i) % M;
	}
	if(n == m)
		cout << (f[n] * f[m] * 2) % M;
	else
		cout << (f[n] * f[m]) % M;
	return 0;
}

Measured memory_bytes: 1024