#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node{
	int x,y;	
}e[1000005];
const ll mod=1e9+7;
ll qp(ll a,ll b){
	ll ans=1,base=a;
	while(b){
		if(b&1){
			ans*=base;
			ans%=mod;
		}
		base*=base;
		base%=mod;
		b>>=1;
	}
	return ans;
}
ll C(ll a,ll b){
	ll ans=1;
	for(int i=a;i>=a-b+1;i--){
		ans*=i;
		ans%=mod;
	}
	for(int i=1;i<=b;i++){
		ans/=i;
	}
	ans%=mod;
	return ans%mod;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	int n,m;
	bool f=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[i].x=u,e[i].y=v;
		if(u!=i||v!=i+1) f=0;
	}
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans*=C(n,i);
		ans%=mod;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j=m-i;j++){
			ans*=(2,m);
		}
	}
	cout<<ans;
	return 0;
}
