#include <iostream>
#include <cstdlib>
using namespace std;

long long solve(long n, long m){
    if(n==0){
        if(m==0){
            return 1;
        }else{
            return 0;
        }
    }else {
        return (n * solve(m,n-1)) % (long long)(1e9 + 7);
    }
}

int main()
{
    int N,M;
    cin >> N >> M;
    cout << (solve(N,M) + solve(M,N)) % (long long)(1e9 + 7) << endl;
}
