#include<bits/stdc++.h>
#define int long long
#define p 1000000007
using namespace std;
int n,m;
bool A=true;
vector<int> a[500005];
int ans;
int q2[500005];
signed main()
{
	ios::sync_with_stdio(false);
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	q2[0]=1;
	for(int i=1;i<=500000;++i)
	{
		q2[i]=(q2[i-1]<<1)%p;
	}
	for(int i=1;i<=m;++i)
	{
		int u,v;
		cin>>u>>v;
		a[u].push_back(v);
		a[v].push_back(u);
		if(u>v) swap(u,v);
		if(u+1!=v) A=false;
	}
	if(A)
	{
		ans+=n;
		for(int l=1;l<=m;++l)
		{
			ans=(ans+(m-l+1)*(q2[l+1]-1)%p*q2[m-l]%p)%p;
		}
		cout<<ans;
		return 0;
	}
	ans+=n;
	cout<<ans;
}