#include<bits/stdc++.h>
using namespace std;
#define pb	push_back
#define s_push(x)	s[++tot] = x
#define s_pop()		tot--
#define s_top()		s[tot]
#define s_size()	tot
const int maxn = 5e5 + 5;
const int mod = 1e9 + 7;
long long a[maxn],fa[maxn][15],dep[maxn],n,m,u,v,f[maxn][2],ans,dc,dcc[maxn],w[maxn],sz[maxn],num,dfn[maxn],low[maxn],dimly,s[maxn],tot,pow2[maxn << 1];
bool bin[maxn],vis[maxn],zyp[maxn];
bool suba = 1;
struct node
{
	int v,nu;
};
vector <int> G[maxn];
vector <node> e[maxn];
inline int read()
{
	int x = 0,f = 1;char ch = getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return f * x;
}
long long qpow(long long a,long long b){long long ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}
long long inv(long long x){return qpow(x % mod,mod - 2);}
void input()
{
	n = read(),m = read();
	if(m != n - 1)
		suba = 0;
	for(int i = 1;i <= m;i++)
	{ 
		u = read(),v = read(),e[u].pb((node){(int)v,i}),e[v].pb((node){u,i});
		if(u != i||v != i + 1)
			suba = 0;
	}
}
void tarjan(int k,int from)
{
	if(dfn[k])
		return ;
	dfn[k] = ++num,low[k] = num;
	bin[k] = 1,s_push(k);
	for(int i = 0;i < (int) e[k].size();i++)
		if(e[k][i].nu != from)
		{
			if(!dfn[e[k][i].v])
				tarjan(e[k][i].v,e[k][i].nu),low[k] = min(low[k],low[e[k][i].v]);
			else
				low[k] = min(low[k],dfn[e[k][i].v]);
		}
	if(dfn[k] == low[k])
	{
		dc++;
		while(bin[k])
			bin[s_top()] = 0,dcc[s_top()] = dc,s_pop();
	}
}
void make_G()
{
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < (int) e[i].size();j++)
			if(dcc[i] == dcc[e[i][j].v])
				dimly++;
			else
				G[dcc[i]].pb(dcc[e[i][j].v]),G[dcc[e[i][j].v]].pb(dcc[i]);
}
void prefix()
{
	for(int i = 1;i <= dc;i++)
		w[i] = 1;
	pow2[0] = 1;
	for(int i = 1;i <= m;i++)
		pow2[i] = pow2[i - 1] * 2 % mod;
	for(int i = 1;i <= n;i++)
		w[dcc[i]] = w[dcc[i]] * 2 % mod;
}
void dfs(int st,int k,int fa)
{
	if(sz[k])
		return ;
	sz[k] = 1;
	f[k][0] = 1;
	f[k][1] = 1;
	for(int i = 0;i < (int) G[k].size();i++)
		if(G[k][i] != fa&&!sz[G[k][i]])
		{
			int v = G[k][i];
			dfs(st,v,k);
			sz[k] += sz[v];
			f[k][1] = f[k][1] * ((f[v][1] + f[v][0] * 2) % mod) % mod;
		}
	f[k][0] = pow2[sz[k] - 1];
	if(k != st)
		f[k][1] = f[k][1] * w[k] % mod - f[k][0];
	else if(k == st)
		f[k][1] = f[k][1] * (w[k] - 1) % mod;
	f[k][1] = (f[k][1] % mod + mod) % mod;
}
void del(int k,int fa)
{
	sz[k] = 0;
	f[k][0] = 0;
	f[k][1] = 0;
	for(int i = 0;i < (int) G[k].size();i++)
		if(G[k][i] != fa&&sz[G[k][i]])
			del(G[k][i],k);
}
void output()
{
	printf("%lld\n",ans * pow2[dimly / 2] % mod);
}
void solve(int k,int fa)
{
	vis[k] = 1;
	dfs(k,k,fa);
	ans = (ans + (f[k][1]) * pow2[dc - sz[k]] % mod) % mod;
	del(k,fa);
	for(int i = 0;i < (int) G[k].size();i++)
		if(G[k][i] != fa&&!vis[G[k][i]])
			solve(G[k][i],k);
}
int LCA(int u,int v)
{
	if(dep[u] < dep[v])
		swap(u,v);
	for(int i = 5;~i;i--)
		if(dep[u] - (1 << i) >= dep[v])
			u = fa[u][i];
	if(u == v)
		return u;
	for(int i = 5;~i;i--)
		if(fa[u][i]&&fa[v][i]&&fa[u][i] != fa[v][i])
			u = fa[u][i],v = fa[v][i];
	return fa[u][0];
}
void dfs0(int k,int de)
{
	dep[k] = de;
	for(int i = 1;i <= 5;i++)
		fa[k][i] = fa[fa[k][i - 1]][i - 1];
	for(int i = 0;i < (int) G[k].size();i++)
		if(G[k][i] != fa[k][0])
			fa[G[k][i]][0] = k,dfs0(G[k][i],de + 1);
}
void check()
{
	int tot = 0,num = 0;
	long long res = 1;
	for(int i = 1;i <= dc;i++)
		if(bin[i])
			a[++tot] = i;
	for(int i = 1;i <= dc;i++)
		vis[i] = 0;
	if(!tot)
		return ;
	int lca = a[1];
	for(int i = 2;i <= tot;i++)
		lca = LCA(lca,a[i]);
	vis[lca] = 1;
	for(int i = 1;i <= tot;i++)
	{
		int pos = a[i];
		while(!vis[pos])
			vis[pos] = 1,pos = fa[pos][0];
	}
	for(int i = 1;i <= dc;i++)
		if(vis[i])
			res = res * (w[i] - 1) % mod,num++;
	res = res * pow2[dc - num] % mod;
	ans = (ans + res) % mod;
}
void calc(int k)
{
	if(k == dc + 1)
	{
		check();
		return ;
	}
	bin[k] = 1,calc(k + 1);
	bin[k] = 0,calc(k + 1);
}
int main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	input();
	for(int i = 1;i <= n;i++)
		if(!dfn[i])
			tarjan(i,-1);
	make_G();
	prefix();
	if(n == 1)
		puts("1");
	else if(suba)
	{
		ans = n * (n - 1) / 2;
		ans %= mod;
		ans = ans * pow2[n - 2] % mod + n * pow2[n - 1] % mod;
		ans %= mod;
		printf("%lld",(ans % mod + mod) % mod);
		
	}
	else if(dc <= 16)
	{
		dfs0(1,-1);
		calc(1);
		output();
	}
	else
	{
		solve(1,-1);
		output();
	}
	return 0 ;
}
/*
NOIP 2022 RP++
*/

