import sys input = sys.stdin.readline N, M = map(int, input().split()) mod = 10 ** 9 + 7 class Factorial: def __init__(self, n, mod): self.mod = mod self.f = [1] for i in range(1, n + 1): self.f.append(self.f[-1] * i % mod) self.i = [pow(self.f[-1], mod - 2, mod)] for i in range(1, n + 1)[: : -1]: self.i.append(self.i[-1] * i % mod) self.i.reverse() def factorial(self, i): return self.f[i] def ifactorial(self, i): return self.i[i] def combi(self, n, k): return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod def permi(self, n, k): return self.f[n] * self.i[n - k] % self.mod f = Factorial(N * 2, mod) res = f.combi(N * 2, N) * (N * 2) % mod #print(res) for _ in range(M): t, x, y = map(int, input().split()) u, v = x, y if t == 1: u += 1 if t == 2: v += 1 if u in range(N) and v in range(N): res -= f.combi(x + y, x) * f.combi(N * 2 - u - v, N - u) % mod res %= mod print(res)