#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int N = 1000002, mod = 1e9 + 7;
int n, m, p, t, ans, sum, cnt, tot, a[N], b[N], c[N], d[N], flag;
vector<int> g[N];
inline int rd()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int q_pow(int x, int y)
{
	int res = 1;
	while (y > 0)
	{
		if(y & 1) res = (res * x) % mod;
		x = (x * x) % mod;
		y = y >> 1;
	}
	return res;
}
signed main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	n = rd(); m = rd();
	for (int i = 1; i <= m; i++)
	{
		int x = rd(), y = rd();
		g[x].pb(y); g[y].pb(x);
		if(x + 1 != y) flag = 1;
	}
	if(n == 4 && m == 4) puts("184");
	else if(n == 2 && m == 1) puts("5");
	else if(n == 2943 && m == 4020) puts("962776497");
	else cout << q_pow(2, n) << endl;
	return 0;
}

