#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool read_(T &ready_get)
{
	T x=0,f=1;
	char ch=getchar();
	while(!('0'<=ch&&ch<='9'))
	{
		if(ch=='-') f=-1;
		if(ch==-1) return false;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9')
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
	ready_get=f*x;
	return true;
}
const long long mod=1e9+7;
struct Edge{int u,v;} e[500007];
int n,m,f[500007];
bool road[500007],cst[500007];
bool next_set(bool *Begin,bool *End)
{
	for(;Begin!=End;++Begin)
		if(*Begin==false) return *Begin=true;
		else *Begin=false;
	return false;
}
int fd_anc(int x)
{
	if(x==f[x]) return x;
	return f[x]=fd_anc(f[x]);
}
void init()
{
	for(int i=1;i<=n;++i)
		f[i]=i;
}
namespace solve1
{
	long long ans=0;
	bool judge()
	{
		for(int i=1;i<=m;++i)
		{
			init();
			if(road[i]) continue;
			for(int j=1;j<=m;++j)
			{
				if(i==j) continue;
				f[fd_anc(e[j].u)]=fd_anc(e[j].v);
			}
			for(int i=1;i<=n;++i)
			{
				if(!cst[i]) continue;
				for(int j=1;j<=n;++j)
				{
					if(!cst[j]) continue;
					if(fd_anc(i)!=fd_anc(j)) return false;
				}
			}
		}
		return true;
	}
	void main()
	{
		while(next_set(cst+1,cst+n+1))
		{
			do
			{
				
				if(judge()) ans=(ans+1)%mod;
			}
			while(next_set(road+1,road+m+1));
		}
		printf("%lld",ans);
	}
}
namespace solve2
{
	long long fast_pow(long long a,long long b)
	{
		long long ans=1;
		a%=mod;
		while(b)
		{
			if(b&1) ans=ans*a%mod;
			a=a*a%mod;
			b>>=1;
		}
		return ans;
	}
	void main()
	{
		printf("%lld",(2*n+n*(n-1)/2)%mod*fast_pow(2,n-2)%mod);
	}
}
int main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	bool flag=true;
	read_(n),read_(m);
	flag&=(m==n-1);
	for(int i=1;i<=m;++i)
	{
		read_(e[i].u),read_(e[i].v);
		flag&=(e[i].u==i&&e[i].v==i+1);
	}
	if(flag) solve2::main();
	else solve1::main();
	return 0;
}