//I love Zhang Shuhao
//10pts
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
const long long p=1000000007;

int n,m;

long long po(long long x){
	long long ans=1,kuai=2;
	while (x>0){
		if (x&1){
			ans=(ans*kuai)%p;
		}
		x>>=1;
		kuai=(kuai*kuai)%p;
	}
	return ans%p;
}

void work_flag1(){
	long long sum=0;
	sum=(sum+po(n-1)*n)%p;
	for (int i=1;i<=n;++i){
		sum=(sum+po(n-2)*(n-i))%p;
	}
	printf("%lld\n",sum);
}	//m=n-1 A

int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	if (n>8){
		for (int i=1;i<=m;++i){
			int x,y;
			scanf("%d%d",&x,&y);
		}
		work_flag1();
		return 0;
	}
	for (int i=1;i<=m;++i){
		int x,y;
		scanf("%d%d",&x,&y);
	}
	fclose(stdin);fclose(stdout);
	return 0;
}
