#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,P=1e9+7;
#define int long long
int n,m;
int qmi(int a,int b){
	int res=1;
	while(b){
		if(b&1) res=res*a%P;
		a=a*a%P;b>>=1;
	}return res;
}
signed main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	for(int i=1,x,y;i<=m;i++) scanf("%lld%lld",&x,&y);
	if(m==n-1){
		int ans=0;
		for(int i=0;i<=m;i++){
			ans=(ans+qmi(2,m-i)*(m-i+1)%P)%P;
		}cout<<ans;
		return 0;
	}
	else
	cout<<(qmi(2,n)-1)*qmi(2,m)%P;
	return 0;
}