#include<bits/stdc++.h>
#define ll long long
#define ve vector<ll>
#define pa pair<ll,ll>
#define pb push_back
#define rd read()
using namespace std;
const ll mod=1e9+7,N=1000005;
ll n,m,a[N],b[N],ans,c[N],o;
ll head[N],cnt,ccnt;
struct s{
	ll to,nxt;
}node[N];
void add(ll x,ll y){
	node[++cnt].nxt=head[x];
	node[cnt].to=y;
	head[x]=cnt;
}
void mult(ll x,ll y){
	head[x]=node[cnt].nxt;
	node[cnt].nxt=0;
	cnt--;
}
ll ksm(ll x,ll k){
	ll p=1;
	while(k){
		if(k&1)p=x*p%mod;
		x=x*x%mod;
		k>>=1;
	}
	return p;
}
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+(c-48);
		c=getchar();
	}
	return f*x;
}
void dfs1(ll x){
	ccnt++;
	c[x]=x;
	for(int i=head[x];i;i=node[i].nxt){
		ll d=node[i].to;
		if(c[d]!=d)dfs1(d);
	}
}
void check(){
	o++;
	if(cnt==0){
		ans+=n;
		return;
	}
	for(int i=1;i<=n;i++)c[i]=0;
	ll p=0;
	ccnt=0;
	for(int i=1;i<=n;i++){
		if(head[i]!=0){
			if(c[i]==0){
				if(p==1){
					ans+=n;
					return;
				}
				dfs1(i);
				p=1;
			}
		}
	}
	ans+=ksm(2,ccnt)-1+(n-ccnt);
	ans%=mod;
}
void dfs(ll x){
	if(x==m+1){
		check();
		return;
	}
	dfs(x+1);
	add(a[x],b[x]);
	add(b[x],a[x]);
	dfs(x+1);
	mult(b[x],a[x]);
	mult(a[x],b[x]);
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	n=rd,m=rd;
	if(m==n-1){
		for(int i=1;i<=m;i++)a[i]=rd,b[i]=rd;
		for(int i=1;i<=m;i++){
			ans+=ksm(2,i+1)*(m-i+1)+n-i;
			ans%=mod;
		}
		printf("%lld\n",(ans)%mod);
		return 0;
	}
	if(n<=20){
		for(int i=1;i<=m;i++)a[i]=rd,b[i]=rd;
		dfs(1);
		printf("%lld",ans);	
	}
	else {
		ans=ksm(2,n+m)-1;
		if(ans<0)ans+=mod;
		printf("%lld\n",ans);
	}
}
