#include<bits/stdc++.h>
#define LL long long

using namespace std;

int n, m;
LL ans;

const int N = 5e5 + 10, M = 2e6 + 10, mod = 1e9 + 7;
int head[N], nxt[M], go[M], tot;
void add(int u, int v) {
	nxt[++ tot] = head[u];
	head[u] = tot;
	go[tot] = v;
}

LL op[M];

int main() {
	freopen("barrack.in", "r", stdin);
	freopen("barrack.out","w",stdout);
	
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> m;
	
	op[0] = 1;
	for (int i = 1;i <= max(n, m);i ++) {
		int u, v;
		cin >> u >> v;
		
		add(u, v); add(v, u);
		
		op[i] = op[i - 1] * 2 % mod;
		// cout << i << ": " << op[i] << '\n';
	}
	
	// cout << op[m] << ' ' << op[n] << '\n';
	cout << op[m] * (op[n] - 1) % mod;
	
	return 0;
}