//10pts, specially A
//I ain't got time!!!
#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
int n, m, u[100005], v[100005], F[100005], cnt[100005];
long long ans;
bool dic[15];
void calc()
{
	long long ans1 = n;
	for (int i = 1; i <= n - 1; i++)
		ans1 = (ans1 * 2) % Mod;
	ans = 0;
	for (int i = 1; i <= n - 1; i++)
		ans = (ans + n - i) % Mod;
	for (int i = 1; i <= n - 2; i++)
		ans = (ans * 2) % Mod;
	printf ("%lld", (ans + ans1) % Mod);
}
//These are all wrong below:
/*int f(int x)
{
	return (F[x] == x) ? x : (F[x] = f(F[x]));
}*/
/*long long cal()
{
	
	memset (cnt, 0, sizeof (cnt));
	for (int i = 1; i <= n; i++)
		F[i] = i;
	long long ans1 = 0;
	for (int i = 1; i <= m; i++)
		if (dic[i])
		{
			int fx = f(u[i]), fy = f(v[i]);
			if (fx != fy)
				F[fy] = F[fx];
		}	
	for (int i = 1; i <= n; i++)
		F[i] = f(i);
	for (int i = 1; i <= n; i++)
		cnt[F[i]]++;
		printf ("\n");
	for (int i = 1; i <= n; i++)
		printf ("%d ", cnt[i]);
	for (int i = 1; i <= n; i++)
	{
		long long tmp = 1;
		for (int j = 1; j <= cnt[i]; j++)
			tmp = (tmp * 2) % Mod;
		printf ("%lld\n", tmp);
		ans1 += tmp - 1;
		ans1 %= Mod;
		printf ("ans1= %lld\n\n", ans1);
	}
	return ans1;
}*/
/*void search (int x)
{
	if (x > n)
		ans = (ans + cal()) % Mod;
	search (x + 1);
	dic[x] = 1;
	search (x + 1);
	dic[x] = 0;
}*/
//:)
int main ()
{
	freopen ("barrack.in", "r", stdin);
	freopen ("barrack.out", "w", stdout);
	
	scanf ("%d%d", &n, &m);
	bool spA = 1;
	for (int i = 1; i <= m; i++)
	{
		scanf ("%d%d", &u[i], &v[i]);
		if (u[i] != i || v[i] != i + 1)
			spA = 0;
	}
	//specially A
	calc();
	return 0;
	
	return 0;
}

