#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long long n,m,u[500005],v[500005];
long long ksm(long long x){
	if(x%2==0)return ksm(x/2)*ksm(x/2)%MOD;
	else return ksm(x/2)*ksm(x/2)*2%MOD;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	    cin>>u[i]>>v[i];
	cout<<ksm(n*(n+3)/2);
}
