#include<bits/stdc++.h>
using namespace std;
#define N 500005
#define ll long long
vector<int> G[N];
int n, m;
ll mod = 1e9+7;
int ru[N];
bool lian = true;
ll jc[N], ny[N], two[N];
ll quick(ll x, ll t){
	ll now = 1;
	while(t){
		if(t & 1) now = now * x % mod;
		x = x * x % mod;
		t >>= 1;
	}
	return now;
}
ll C(ll x, ll y){
	if(x < y) return 0;
	return jc[x] * ny[y] % mod * ny[x - y] % mod;
}
int main(){
	freopen("barrack.in", "r", stdin);
	freopen("barrack.out", "w", stdout);
	cin>>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);
		ru[u] ++;
		ru[v] ++;
		if(ru[u] > 2 || ru[v] > 2) lian = false;
	}
	jc[0] = ny[0] = two[0] = 1;
	for(int i=1;i<=n;i++) {
		jc[i] = jc[i-1] * i % mod;
		two[i] = two[i-1] * 2 % mod;
		ny[i] = quick(jc[i], mod - 2);
	}
	if(m == n - 1) {
		ll ans = two[n-2] * C(n, 2) % mod + n * two[n-1] % mod;
		printf("%lld\n", ans % mod);
		return 0;
	}
}
