mod = 10**9+7 n, m = map(int, input().split()) u = 10**6 ans = 0 F = [1]*(u+1) for i in range(u): F[i+1] = F[i]*(i+1)%mod I = [1]*(u+1) I[u] = pow(F[u], mod-2, mod) for i in range(u)[::-1]: I[i] = I[i+1]*(i+1)%mod def comb(n, k): if 0 <= k <= n: return F[n] * I[k] % mod * I[n-k] % mod return 0 ans = comb(2*n, n) * 2 * n ans %= mod for _ 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-y) else: ans -= comb(x+y, x) * comb(2*n-(x+y+1), n-x) ans %= mod print(ans)