#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; const int MAX=510000; const int MOD=1000000007; ll fac[MAX],finv[MAX],inv[MAX]; void init(){ fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i>n>>m; ll ans=nCr(2*n,n)*2%MOD*n%MOD; rep(i,m){ int t; ll x,y; cin>>t>>x>>y; if(t==1) ans=(ans-nCr(x+y,x)*nCr(2*n-x-y-1,n-y)%MOD+MOD)%MOD; else ans=(ans-nCr(x+y,x)*nCr(2*n-x-y-1,n-x)%MOD+MOD)%MOD; } cout<