#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
long long moo=1000000007;
int n,m,lk,a[1000010],b[1000010],f[1000010];
long long ans=0,sum,lkkk=1,lp;
long long ksm(long long x,long long y){
	long long num=1;
	while(y){
		if(y&1) num=num*x%moo;
		y>>=1;
		x=x*x%moo;
	}
	return num;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	
	scanf("%d%d",&n,&m);
	if(m!=n-1) lkkk=0;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]>b[i]) swap(a[i],b[i]);
		if(a[i]==i&&b[i]!=a[i]+1) lkkk=0;
	}
	if(lkkk){
		long long sum=ksm(2,m)%moo;
		sum=n*sum%moo;
		sum=(sum+n*(n-1)/2*ksm(2,n-2)%moo)%moo;
		printf("%lld",sum);
	}
	else printf("%lld",ksm(2,m));
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}