#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100, MOD = 1e9 + 7, MAXC = 16;
int N, C[MAXN];
long long K, A[MAXN], B[MAXN];
vector<vector<long long> > M(MAXC, vector<long long>(MAXC));
vector<vector<long long> > ans(MAXC, vector<long long>(MAXC));
vector<vector<long long> > mult(vector<vector<long long> > A,
                                vector<vector<long long> > B) {
  vector<vector<long long> > C(MAXC, vector<long long>(MAXC));
  for (int r = 0; r < (int)MAXC; r++)
    for (int c = 0; c < (int)MAXC; c++) {
      C[r][c] = 0;
      for (int k = 0; k < (int)MAXC; k++)
        C[r][c] = (A[r][k] * B[k][c] % MOD + C[r][c]) % MOD;
    }
  return C;
}
vector<vector<long long> > sq(vector<vector<long long> > M) {
  return mult(M, M);
}
vector<vector<long long> > f(vector<vector<long long> > m, long long e) {
  if (e > 0) {
    m = sq(f(m, e / 2));
    if (e % 2 == 1) m = mult(m, M);
  } else {
    for (int r = 0; r < (int)MAXC; r++)
      for (int c = 0; c < (int)MAXC; c++) m[r][c] = r == c;
  }
  return m;
}
int main() {
  scanf("%d", &N), scanf("%lld", &K);
  for (int i = 0; i < (int)N; i++)
    scanf("%lld", &A[i]), scanf("%lld", &B[i]), scanf("%d", &C[i]);
  B[N - 1] = K;
  for (int r = 0; r < (int)MAXC; r++)
    for (int c = 0; c < (int)MAXC; c++) ans[r][c] = r == c;
  for (int i = 0; i < (int)N; i++) {
    for (int r = 0; r < (int)MAXC; r++)
      for (int c = 0; c < (int)MAXC; c++) M[r][c] = 0;
    for (int c = 0; c < (int)C[i] + 1; c++) M[c][c] = 1;
    for (int c = 0; c < (int)C[i]; c++) M[c][c + 1] = 1;
    for (int c = 1; c < (int)C[i] + 1; c++) M[c][c - 1] = 1;
    M = f(M, B[i] - A[i]);
    ans = mult(ans, M);
  }
  printf("%lld\n", ans[0][0]);
}
