#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define endl "\n"
#define MOD 1000000007
#define inf 1e18
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ld long double
typedef long long ll;

bool comparator(const pair<int,int> &a, const pair<int, int> &b )
{
    return (a.second<b.second);
}
bool cmp(const string &a,const string &b)
{
    if(a.length()<b.length())
        return true;
    return false;
}

ll modpower(ll a,ll b,ll c)
{
	ll res=1LL;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//set<ll> s[100005];
/*
void primeFactors(ll i,ll n)
{

    while (n % 2 == 0)
    {
        s[i].insert(2);
        //cout << 2 << " ";
        n = n/2;
        s[i].insert(n);
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            s[i].insert(i);
           // cout << i << " ";
            n = n/i;
            s[i].insert()
        }
    }

    if (n > 2)
        s[i].insert(n);
*/
int main() {
    run;
    ll t;
    t=1;
    ll j=1;


    while(t--)
    {
        ll n;
        cin>>n;
        ll m;
        cin>>m;
        ll a=n,b=m;
        n=min(a,b);
        m=max(a,b);
        if(n==1)
        {
            cout<<2*m<<endl;
        }else{

        ll p=modpower(2,n,MOD);
        if(m==n && m>2)
        {
            cout<<(p*2)%MOD;
            return 0;
        }
        ll dif=m-n+1;
        if(m>2)
        {
            dif*=2;
        }
            ll o=(dif*p)%MOD;
        cout<<o;
        }



    }





}
