#include<bits/stdc++.h>
#define ll long long

using namespace std;
const ll mod=1e9+7;
const int N=5e5+10;
const int M=1e6;
int debug=0;
ll n,m;
vector<int> g[N];

ll qpow(ll _,ll __) //_^__
{
	ll ___=1;
	while(__)
	{
		if(__&1) ___=(___*_)%mod;
		_=(_*_)%mod;
		__>>=1;
	}
	return ___;
}
int st[N],top=0;
bool vis[N];
ll size=0;
int dfs(int u,int fa)
{
	int fl=0;
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(v!=fa&&!vis[v])
		{
			st[++top]=v;
			vis[v]=true;
			fl=dfs(v,u);
			if(fl) return 1;
			top--;
			vis[v]=false;
		}
		if(v!=fa&&vis[v])
		{
			while(st[top]!=v)
			{
				top--;
				size++;
			}
			size++;
			return 1;
			
		}
	}
	return 0;
}
int main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	scanf("%lld%lld",&n,&m);
	if(m==n-1)
	{
		printf("%lld\n",((1ll*n*(n-1)/2)%mod+n*qpow(2,m)%mod)%mod);
	}
	else if(n==m)
	{
		for(int i=1;i<=m;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			g[u].push_back(v);
			g[v].push_back(u);
		}
		st[++top]=1;
		vis[1]=true;
		dfs(1,-1);
		top--;
		vis[1]=false;
		ll ans=n*qpow(2,m)%mod;
		ans=(ans+size*(size-1)%mod)%mod;//r->r
		ans=(ans+(size-1)*(n-size)%mod+(n-size))%mod;//r->l
		ans=(ans+(n-size)*(n-size-1)/2%mod)%mod;//l->l
		if(debug) printf("%lld\n",size);
		if(debug) printf("%lld\n",size*(size-1)%mod+(size-1)*(n-size)%mod+(n-size)%mod+(n-size)*(n-size-1)/2%mod);
		printf("%lld\n",ans);
	}

	return 0;
}
