#include<bits/stdc++.h>
#define int long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define foR(i,a,b) for(int i=(a);i>=(b);i--)
#define inf 0x3f3f3f3f
#define pii pair<int,int>
using namespace std;
const int N=5e5+5,MOD=1e9+7;
struct node{int u,nxt,to;}e[N<<1];
int h[N<<1],num_e=0;
inline void add(int x,int y) {
	e[++num_e].nxt=h[x];
	e[num_e].u=x;
	e[num_e].to=y;
	h[x]=num_e;
}
int n,m;
bool flag=true;
inline int pp(int p) {
	if(p==0) return 1;
	if(p==1) return 2;
	int x=pp(p/2)%MOD;
	if(p&1) return x*x*p%MOD;
	else return x*x%MOD;
}
int sz[N],d[N];
inline void build(int x,int fa) {
	sz[x]=1,d[x]=d[fa]+1;
	for(int i=h[x];i;i=e[i].nxt) {
		int y=e[i].to;
		if(y==fa) continue;
		build(y,x);
		sz[x]+=sz[y];
	}
}
signed main() {
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	if(m!=n-1) flag=false;
	For(i,1,m) {
		int x,y;
		scanf("%lld%lld",&x,&y);
		add(x,y),add(y,x);
		if(abs(x-y)!=1) flag=false;
	}
	if(flag) {
		int ans=0;
		For(i,1,n) ans=(ans+pp(n-1))%MOD;
		For(len,1,n-1) ans=(ans+pp(n-2))%MOD;
		return printf("%lld\n",ans),0;
	}
	else if(m==n-1) {
		memset(sz,0,sizeof(sz));
		build(1,0);
		int ans=0;
		int k=pp(n)-1;
		For(i,1,2*m) {
			if(d[e[i].to]<d[e[i].u]) continue;
			int k1=pp(sz[e[i].to]-1)%MOD,
				k2=pp(n-sz[e[i].to]-1)%MOD;
			ans=(ans+2*k1+2*k2)%MOD;
//			cout<<k1<<" "<<k2<<"\n";
			ans=(ans+k-k1-k2+MOD)%MOD;
		}
		return printf("%lld\n",ans),0;
	}
	return 0;
}
