#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define pii pair < int32_t , int32_t >
#define Endl '\n'
 
#pragma GCC optimize("Ofast")
 
using namespace std;
 
mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
 
const ll mod = 1e9 + 7;
const int32_t FFTM = 998244353;
const int32_t N = 50000;
ll step (ll n,ll m)
{
    if (m==0) return 1;
    else if (m%2) return ((step(n,m-1))%mod*(n%mod))%mod;
        else {
        ll b = step(n,m/2);
        b%=mod;
        return (b*b)%mod;
    }
}
int32_t SX[4] = {0 , 1 , -1 , 0};
int32_t SY[4] = {1 , 0 , 0 , -1};
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
ll n,m;
cin>>n>>m;
ll fact1 = 1;
ll fact2 = 1;
    ll fact3 = 1;
    if (n<m) swap(n,m);
    for (int i = 1;i<=n;i++)
    {
        fact1*=i;
        fact1%=mod;}
    for (int i = 1;i<=m;i++)
    {
        fact2*=i;
        fact2%=mod;
    }
    for (int i = 1;i<=n-m;i++)
    {
        fact3*=i;
        fact3%=mod;
    }
  cout<<step(2,n)*max(1LL,m-1);
    return 0;}
