#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

const int MAXN = 500005, MAXM = 2000006;
const int P = 1000000007;
typedef long long ll;
int n, m, head[MAXN], p2[MAXN], Head[MAXN], sze[MAXN], szv[MAXN], tot, dc[MAXN], dfn[MAXN], low[MAXN];
int stk[MAXN], stp;
struct E {
	int u, v, next;
} e[MAXM], e_[MAXM];

struct S {
	int st, sn, ss;
};

void add(int u, int v) {
	static int t = 1;
	t++;
	e[t].u = u;
	e[t].v = v;
	e[t].next = head[u];
	head[u] = t;
}

void Add(int u, int v) {
	static int t = 0;
	t++;
	e_[t].u = u;
	e_[t].v = v;
	e_[t].next = Head[u];
	Head[u] = t;
}

void tarjan(int rt, int fa) {
	static int t = 0;
	dfn[rt] = ++t;
	low[rt] = t;
	stk[++stp] = rt;
	for (int i = head[rt]; i; i = e[i].next) {
		int v = e[i].v;
		if (v == fa) continue;
		if (!dfn[v]) {
			tarjan(v, rt);
			low[rt] = min(low[rt], low[v]);
		}
		else if (dfn[v] < low[rt]) low[rt] = dfn[v];
		else {
			low[rt] = min(low[rt], low[v]);
		}
	}
	//printf("dfn[%d]=%d, low[%d]=%d\n", rt, dfn[rt], rt, low[rt]);
	if (dfn[rt] == low[rt]) {
		tot++;
		while (stk[stp] != rt) {
			dc[stk[stp]] = tot;
			szv[tot]++;
			stp--;
		}
		szv[tot]++;
		dc[rt] = tot; stp--;
	}
}

void solve1() {
	tarjan(1, 0);
	for (int i = 1; i <= m; i++) {
		if (dc[e[i*2].u]==dc[e[i*2].v]) {
			sze[dc[e[i*2].u]]++;
		}
		else {
			Add(dc[e[i*2].u], dc[e[i*2].v]);
			Add(dc[e[i*2].v], dc[e[i*2].u]);
		}
	}
	//printf("%d\n", tot);
	if (tot == 1) {
		printf("%d\n", ((ll)p2[n]*p2[m]%P-1+P)%P);
	}
	else if (tot == 2) {
		int a1 = (ll)p2[sze[1]]*(p2[szv[1]]-1)%P;
		int a2 = (ll)p2[sze[2]]*(p2[szv[2]]-1)%P;
		int a3 = (ll)(p2[n])*p2[m-1]%P;
		printf("%d\n", ((a1+a2+a3-1)%P+P)%P);
	}
	else {
		printf("114514\n");
	}
}

int main() {
	freopen("barrack.in", "r", stdin);
	freopen("barrack.out", "w", stdout);
	scanf("%d %d", &n, &m);
	int u, v;
	bool b = (m==n-1);
	for (int i = 1; i <= m; i++) {
		scanf("%d %d", &u, &v);
		b &= (max(u,v)-min(u,v)==1);
		add(u, v); add(v, u);
	}
	p2[0] = 1;
	for (int i = 1; i <= n; i++) p2[i] = (p2[i-1]<<1)%P;
	if (b) {
		int ans = ((((ll)n*(n-1)/2)%P)*(ll)p2[n-2]%P+(ll)p2[n-1]*n%P)%P;
		printf("%d\n", ans);
	}
	else {
		solve1();
	}
	return 0;
}