#include<bits/stdc++.h>
using namespace std;

int n,m,uu,vv,x,ans;
int const MOD=1e9+7;
bool flag;
int ksm(int a,int b)
{
	x=1;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return x%MOD;
}
signed main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	ans=0;
	flag=true;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		if(abs(u-v)!=1) flag =false;
	}
	if(m==n-1)
	{
		if(flag)
		{
			for(int i=1;i<=n;i++)
			{
				if(i==1) ans=(ans+(n*ksm(2,m))%MOD)%MOD;
				else ans=(ans+(((ksm(2,i-2)*ksm(2,n-i))%MOD)*(n-i+1))%MOD)%MOD;
			}
			cout<<ans<<endl;
		}
	}
}
