#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define M 1000010
#define N 500010
int read() {
	int s=0; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
int n,m,rdu[N],cdu[N];
struct node {
	int to,next;
}e[M*2];
int head[N],cnt;
void add(int u,int v) {
	e[++cnt].to=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}
ll pow(int a,int b) {
	ll aa=1ll*a;
	ll res=1;
	while(b) {
		if(b&1) res=res*aa%mod;
		aa=aa*aa%mod;
		b/=2;
	}
	return res;
}
int main() {
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	n=read(); m=read();
	bool flag=true;
	for(int i=1;i<=m;i++) {
		int u,v; u=read(); v=read();
		cdu[u]++; rdu[v]++;
		if(cdu[u]>1 || rdu[v]>1) flag=false;
		add(u,v); add(v,u);
	}
	if(flag) {
		printf("%lld",1ll*n*(n-1)%mod*pow(2,n-3)%mod);
	}
	else printf("0");
	return 0;
}
