#include <bits/stdc++.h>
using namespace std;
const int N=5e5+10,M=1e9+7;
int n,m,u,v;
long long int cnt;
vector <int>g[N];
inline int read(){
	int f=1,sum=0;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		sum=sum*10+(int(ch-'0'));
		ch=getchar();
	}
	return sum*f;
}

int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	n=read(),m=read();
	int flag=1;
	for(int i=1;i<=m;i++){
		u=read(),v=read();
		g[u].push_back(v);
		g[v].push_back(u);
		if(abs(u-v)!=1){
			flag=0;
		}
	}
	if(n!=m+1)
		flag=0;
	if(flag==1){
		cnt+=(n*int(pow(2,m)));
		cnt%=M;	
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				int x=j-i-1;
				if(x==0){
					cnt+=(pow(2,(m-1)));
					cnt%=M;	
				}
				else{
					cnt+=(pow(2,(m-(x+1)))*pow(2,x));
					cnt%=M;				
				}
			}
		}
		cout<<cnt%M<<endl;
		return 0;
	}
	if(n==2)
		cout<<5<<endl;
	else if(n==3)
		cout<<49<<endl;
	cout<<cnt%M<<endl;
	return 0;
}