#include<bits/stdc++.h>
using namespace std;
int n,m,e[1000005][2],fa[500005],a[500005],tot;
long long ans;
const long long p = 1e9+7;
bool lian;
long long qpow(long long x,long long b){
	long long re = 1;
	while(b){
		if(b&1)re = re*x%p;
		x = x*x%p;
		b >>= 1;
	}
	return re;
}

int find(int x){
	if(x == fa[x])return x;
	fa[x]=find(fa[x]);
	return fa[x];
}

void uni(int x, int y){
	x = find(x);
	y = find(y);
	if(x!=y)fa[x]=y;
}

void sol1(){
	for(int i = 1; i < (1 << n); i++){
		tot = 0;
		for(int j = 1; j <= n; j++){
			if((1 << (j-1))&i)a[++tot]=j;
		}
		long long cnt = m;
		for(int j = 1; j <= m; j++){
			for(int k = 1; k <= n; k++){
				fa[k]=k;
			}
			for(int k = 1; k <= m; k++){
				if(k!=j)uni(e[k][1],e[k][0]);
			}
			bool flag = 0;
			for(int p = 1; p < tot; p++){
				for(int q = p+1; q <= tot; q++){
					if(find(a[p])!=find(a[q])){
						flag = 1;
						break;
					}
				}
				if(flag)break;
			}
			if(flag)cnt--;
		}
		ans+=qpow(2,cnt);
		ans%=p;
	}
	cout << ans;
}

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",&e[i][0],&e[i][1]);
		if(!(e[i][0]==i&&e[i][1]==i+1))lian=1;
	}
	if(n<=16 && m <= 25)sol1();
	else if(!lian){
		long long k = n;
		if(n==1)cout << 1;
		else cout << ((k*(k+3)/2)%p*qpow(2,k-2))%p;
	}
	return 0;
}
/*
4 3
1 2
2 3
3 4
*/