#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll P=1e9+7;
ll n,m,i,k,ans;
inline ll qpow(ll a,ll x){
	if(x<=0)return 1;
	if(x==1)return a%P;
	if(x==2)return (a*a)%P;
	if(x%2==0)return qpow((a*a)%P,x/2);
	else return qpow((a*a)%P,x/2)*a%P;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	scanf("%d%d",&n,&m);
	k=qpow(2,n-2);
	//cout<<k<<endl;
	ans=((k*n*(n-1)/2)+k*2*n)%P;
	printf("%lld",ans);
}
