#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mo=1e9+7;
const int N=1000005,M=20000006;
int n,m,f[N][2],u[M],v[M];
ll qpow(int r)
{
	ll res=1LL,x=2LL;
	while (r)
	{
		if (r&1) res=res*x%mo;
		x=x*x%mo;
		r>>=1;
	}
	return res;
}
int main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i)
		scanf("%d%d",&u[i],&v[i]);
	if (m==n-1)
	{
		printf("%lld",(n*(n-1)/2%mo*qpow(n-2)%mo+n*qpow(n-1)%mo)%mo);
		return 0;
	}
	return 0;
}
