import sys import io, os input = sys.stdin.buffer.readline #input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def main(): N = 10**6 mod = 10**9+7 fac = [1]*(N+1) finv = [1]*(N+1) for i in range(N): fac[i+1] = fac[i] * (i+1) % mod finv[-1] = pow(fac[-1], mod-2, mod) for i in reversed(range(N)): finv[i] = finv[i+1] * (i+1) % mod def cmb1(n, r, mod): if r <0 or r > n: return 0 r = min(r, n-r) return fac[n] * finv[r] * finv[n-r] % mod n, m = map(int, input().split()) s = 4*fac[2*n-1] p = (fac[n-1]**2)%mod s *= pow(p, mod-2, mod) s %= mod TXY = [] for i in range(m): t, x, y = map(int, input().split()) if t == 1: s -= cmb1(x+y, x, mod)*cmb1(2*n-x-y-1, n-y, mod) else: s -= cmb1(x+y, x, mod)*cmb1(2*n-x-y-1, n-x, mod) s %= mod print(s%mod) if __name__ == '__main__': main()