N,M=map(int,input().split()) mod=10**9+7 fac=[1] for i in range(1,N*2+1): fac+=fac[-1]*i, def comb(n,k): return fac[n]*pow(fac[k],mod-2,mod)*pow(fac[n-k],mod-2,mod)%mod ans=comb(2*N,N)*N*2 for i in range(M): t,x,y=map(int,input().split()) if t==1: ans-=comb(x+y,x)*comb(2*N-x-y-1,N-x-1) if t==2: ans-=comb(x+y,y)*comb(2*N-x-y-1,N-y-1) print(ans%mod)