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