#include<bits/stdc++.h>
#define rint register int
#define ll long long
#define mod 1000000007
#define N 100005
using namespace std;
int n,m;
int u,v;
int zbs[1005][1005];
long long lyic[500005];
int main()
{
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (rint i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		zbs[u][v]=zbs[v][u]=1;
	}
	lyic[1]=1;
	lyic[2]=5;
	for (int i=3;i<=n;i++)
		lyic[i]=(1ll)*(lyic[i-1]*3+i+1)%mod;
	printf("%lld",lyic[n]);
	fclose(stdin);fclose(stdout);
	return 0;
}