#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;const int N=5e5;
int n,m,head[N],tot,ans;
struct edge{
	int ne,to;
}e[N<<1];
inline ll c(int x,int y){
	if(x==y)return 1;
	if(x<y/2)x=y-x;ll res=1;
	for(int i=y;i>=y-x;i-=1){
		res*=i;
	}
	return res;
}
int main(){
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;bool flag=1;
	for(int i=1;i<=m;++i){
		int x,y;cin>>x>>y;if(x!=y+1&&x!=y-1)flag=0;
	}
	if(m==n-1&&flag){
		ll cm=0;
		for(int i=1;i<=m;++i){
			if(!i%10)cm%=mod;
			cm+=c(i,m)+1;
		}
		for(int i=1;i<=n;++i){
			if(!i%10)ans%=mod;
			ans+=c(i,n)*cm;
		}
		cout<<ans-1<<endl;
	}
	return 0;
}
/*
kai shi bioa bai (ji shi mei you chinese shu ru fa:
wo ai kkks03!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
kao wan NOIP ying gai jiu AFO le ba xie xie luogu zhe ji nina lai dui wo de pai ban 
zhen xin gan xie 
ji shi wo xue de zhen de shi hen lan 
dan shi wo xiang xin zhe duan shi guang yi ding hui cheng wei wo yi hou chu niu de zi ben 
yi hou wo jian ren jiu han I LOVE KKK!&&I LOVE LUOGU!
zui hou mo bai dalao karanoli
*/